• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Loading Compiled AppleScript from Main Bundle???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: How to make an NSTextField the First Responder?
  • Next by Date: Re: Newbie Locating Fonts Question
  • Previous by thread: [SOLVED] Re: Looking for performance-oneway asynch call
  • Next by thread: Re: Newbie Locating Fonts Question
  • Index(es):
    • Date
    • Thread