Skip navigation.
 
mlRe: Calling an Applescript from Cocoa Java App
FROM : Ian Gillespie
DATE : Mon Jan 14 22:46:41 2002

>> I think this should be easy, but I can't get it to work. I hooked up a
>> button in interface builder to an Applescript script. I added the
>> script
>> to Project Builder and put some basic code in it. But when I run the
>> app
>> and try to open the window with the button on it I get the following
>> error:
>>
>>
>> class error for 'ASKNibObjectInfoManager': class not loaded
>>
>>
>> I added two Applescript frameworks to the project but it still doesn't
>> work. Anyone got any suggestions of what I need to do. I am a novice
>> programmer so the more detail the better.

>
> This is your second post of this question. I think you haven't gotten
> any
> answers because nobody understands your question.


> You suggest that you started by creating an AppleScript script file
> somehow,
> but you don't say how. Since you say you "added" it to Project Builder,
> it
> sounds like you created the script in some other application, external
> to
> Project Builder. Did you use Script Editor? If so, I'm curious to know
> whether you saved it as a text file, or a compiled script, or a script
> application -- although it wouldn't make any difference, since you
> can't use
> either of the latter two kinds of files in Project Builder. Or did you
> use
> Text Edit and just type in some AppleScript code? Or am I wrong in
> understanding that you started by creating a script externally to
> Project
> Builder?
>
> What do you mean when you say you "added the script to Project Builder"?
> What did you add? From where? How did you "add" it?
>
> What do you mean when you say you "put some basic code in it"? The
> order of
> your presentation suggests that you did this after "adding" some
> original
> script to Project Builder. How did you do this? Did you just use Project
> Builder's internal text editor to type in some AppleScript statements?
>
> And you say you "hooked up a button in interface builder" to this
> script.
> How did you do that?
>
> Have you described the order in which you did these things correctly?
> It's
> hard to tell from your question, but I understand from your description
> that, in this order, (1) you created an AppleScript script somehow, (2)
> you
> added it to Project Builder somehow, (3) you put some (more?)
> (AppleScript?)
> code in it somehow, (4) you added two AppleScript frameworks to the
> project
> (you don't say which frameworks), (5) you hooked up the script file to a
> button in Interface Builder somehow, (6) you built the application
> (successfully, I assume, although I don't see how), and (7) you ran it
> and
> got a runtime error (or maybe you combined steps 6 and 7 and got a
> compiler
> or linker error).
>
> I ask these questions, because just about every step you describe sounds
> like nothing you're supposed to be able to do in Project Builder or
> Interface Builder. Your description sounds as if you created a script in
> some external application (Script Editor? Text Edit?), then used Project
> Builder's "Add Files" command to add it to your project (or maybe you
> just
> dragged it into the Project Builder folder in the Finder), then used
> Project
> Builder's internal text editor to type in some more AppleScript code.
> You
> can do all those things, but I don't know how you would get from there
> to
> hooking the script up to a button in Interface Builder. AppleScript
> files
> can't just be typed or loaded and then executed in this fashion AFAIK,
> if
> that's what you're doing.
>
> If you're using AppleScript Studio, you need to work through the manual
> and
> the examples, which should answer this sort of question. The error
> you're
> getting makes it sound as if Project Builder is looking for the
> AppleScriptKit.framework ("ASK") but can't find it -- presumably
> because you
> haven't installed AppleScript Studio.
>
> And, in the current Mac OS X, you don't normally have to explicitly add
> any
> AppleScript frameworks to a project. If you're trying to build a
> scriptable
> Cocoa application (which doesn't sound like what you're doing), the
> necessary frameworks are included by including Cocoa.framework AFAIK.
> Unless
> you're trying to build a Cocoa application that is scriptable with the
> new
> AppleScript Studio dictionaries, which does require including
> AppleScriptKit.framework AFAIK. If you're just trying to use AppleScript
> Studio to build an AppleScript application, just installing AppleScript
> Studio from the Developer Tools CD and opening one of the three provided
> AppleScript Studio templates is all you need to do -- they include
> AppleScriptKit.framework along with Cocoa.framework already.
>
> Sorry if I've misunderstood your question. But it leaves me with the
> impression that you need to do some very basic reading in the Cocoa
> documentation before you go any farther. I tend to get somewhat testy
> when I
> can't understand a question, which explains the tone of this reply.
>
> --
>
> Bill Cheeseman - <email_removed>
> Quechee Software, Quechee, Vermont, USA
> http://www.quecheesoftware.com


Sorry if my question was not clear.  Here is a more step by step
description of what I did.

I have an app that works fine--it builds and runs.  I opened up one of
it's nib files in IB and added a button (NSButton) to a window
controlled by that nib file.  On the IB Inspector, I selected
AppleScript from the popup menu and then selected the newly added
NSButton on the window.  I then checked the "action" checkbox and
"clicked" checkbox under event handlers on the IB Inspector.  I then
clicked "New Script" from the IB Inspector and it asked if I wanted to
add the script to my project in PB, I gave it a name (let's call it
aScript) and saved it and the aScript.applescript appeared in project
builder along with my .java files.

Up to this point, I was under the impression that when my button would
be clicked, it would call the script that was just added to project
builder from interface builder.  In PB I edited the script to this:

on clicked theObject
   tell application "Mail"
       
   end tell
end clicked

The app compiles fine and launches, but when I try to open the window
which has the button on it, I get the error I mentioned above and the
app crashes.  Any suggestions?


Related mailsAuthorDate
mlCalling an Applescript from Cocoa Java App Ian Gillespie Jan 14, 17:05
mlRe: Calling an Applescript from Cocoa Java App Bill Cheeseman Jan 14, 18:07
mlRe: Calling an Applescript from Cocoa Java App Ian Gillespie Jan 14, 22:46
mlRe: Calling an Applescript from Cocoa Java App Bill Cheeseman Jan 14, 23:19
mlRe: Calling an Applescript from Cocoa Java App Ian Gillespie Jan 15, 00:14
mlRe: Calling an Applescript from Cocoa Java App Chris Beauvois Jan 15, 04:39
mlRe: Calling an Applescript from Cocoa Java App Ian Gillespie Jan 15, 07:47
mlRe: Calling an Applescript from Cocoa Java App Chris Beauvois Jan 15, 19:24