Loading Compiled AppleScript from Main Bundle???
Loading Compiled AppleScript from Main Bundle???
- Subject: Loading Compiled AppleScript from Main Bundle???
- From: Dale Gillard <email@hidden>
- Date: Fri, 1 Nov 2002 21:54:39 +1100
Hi all
I'm not able to load and execute a compiled AppleScript that sits
within my app's Bundle and was hoping someone may be able to help. See
the code below (I've omitted lines releasing the variables created for
brevity).
When I build the app I can see the compiled script has been saved into
my Bundle's resources folder. And NSLog(theCompiledScript) shows me
that the compiled script is being found at runtime. But
NSLog([theResult stringValue]) shows nothing - the script returns a
string.
The strange thing is, if I uncomment:
//theCompiledScript = @"/ASGetFrontWindowBounds.scpt;
and use it instead of the pathForResource: ofType: message then the
AppleScript is executed fine and the expected string is logged.
Is there something special about executing AppleScripts from within
your bundle? I couldn't find anything mentioned about this is the docs
for NSBundle, NSAppleScript or on the list archives.
Many thanks for any assistance!
Dale
//---------------------------------------
NSString *theCompiledScript;
theCompiledScript = [[NSBundle mainBundle]
pathForResource:@"ASGetFrontWindowBounds" ofType:@"scpt"];
//theCompiledScript = @"/ASGetFrontWindowBounds.scpt";
NSLog(theCompiledScript);
NSAppleEventDescriptor *theResult;
NSDictionary *theError = [NSDictionary dictionary];
NSURL *theURL = [[NSURL alloc] initFileURLWithPath:theCompiledScript];
NSAppleScript *theScript = [[NSAppleScript alloc]
initWithContentsOfURL:theURL error:&theError];
theResult = [theScript executeAndReturnError:&theError];
NSLog([theResult stringValue]);
//---------------------------------------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.