Re: Calling Script Objects in Applescript
Re: Calling Script Objects in Applescript
- Subject: Re: Calling Script Objects in Applescript
- From: has <email@hidden>
- Date: Sat, 14 Mar 2009 12:54:13 +0000
Karen van Eck wrote:
We have a lot of code in libraries in Applescript. Now starting to
look at using Cocoa to move forward, as we are really using
Applescript to pretty much its limit.
But it is not a short term solution to rewrite all our Applescript
libraries in Objective-C. We need to be able to use Objective-C
programs to load and execute our Applescripts.
I've managed to get a program to execute an Applescript and to execute
a handler in an Applescript.
But most of our libraries are saved as Script Objects. Please could
someone point me in the right direction for executing a subroutine
inside a script object in an Applescript.
Neither NSAppleScript nor OSAKit wrappers expose the APIs you need for
this, therefore, you will need to use the Carbon OSA APIs directly.
Use OSALoadFile to load the script, OSAGetProperty to copy the script
object into a new slot, and OSAExecuteEvent to invoke its handlers.
You can save yourself a bunch of work if you use objc-appscript's
AEMCodecs class to convert your Cocoa objects (NSStrings, NSArrays,
etc.) to/from NSAppleEventDescriptors, which in turn are easily
converted to Carbon AEDescs. There's an example project,
CallAppleScriptHandler, in the objc-appscript repository that shows
how to do most of this.
BTW, best place for these sorts of questions is applescript-
implementors:
http://lists.apple.com/mailman/listinfo/applescript-implementors
More focused, less crowded.
HTH
has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden