Calling AppleScript Handler from Cocoa Application in PB

I’m building a Cocoa app and I’m very new to Objective-C. I have a library of AppleScript handlers that I would like to call from my Cocoa app passing variable parameters to the various handlers but I’m stumped how to make this work. I understand how to call a script and have it return a value from the explicit run handler but not other handlers and not passing parameters.

Thanks,
Jon

I don’t know if this works with a Cocoa app (can you use a script to call another script?) but say you have a script with the following handlers.

to add2numbers(n, nn)
	return n + nn
end add2numbers

to mulitply2numbers(n, nn)
	return n * nn
end mulitply2numbers

Now you can load this script and call the various handlers within it.

set foo to load script file "path:to:library"
set multiplied_ to foo's mulitply2numbers(2, 6)
--> 12

set sum_ to foo's add2numbers(2, 1)
--> 3

Is that what you need?

Rob, thanks, but I don’t think that’s what I need. I found this posting online and I think it is more along the lines of what I want to do but I can’t figure out how to make it work (the author didn’t respond to my query even though I promised valuable rewards for some illumination).

Jon

Ok, I was afraid of that. Sorry I can’t offer more.

– Rob

Jon,

Here’s a post to the applescript-users mailing list that might be helpful.

Thank, Rob!

Jon

Jon, I don’t know if you subscribe to the applescript-studio list so here’s something else that popped up today and might be useful.

DocGlue was created as a global data store for all your AppleScript Studio scripts. It can remember values for later, then recall those same values in another script. The download package includes an Objective-C class (doing all the work), an AppleScript library (talking to the Objective-C class), documentation, and a Sample project.

– Rob

Rob, thanks for being on the lookout. I don’t subscribe to the list but I do search it (and others) periodically using the excellent and invaluable iList. I’ll take a look at DocGlue and let you know how that goes as well.

Thanks,
Jon

Thanks for the pointer to iList, a bit quirky at first, but absolutely wonderful. Never again will I have to trawl through those huge text files on the carbon and quicktime lists. It would be good but not quite so necesary if iList could work on these lists as well.

Kevin