inconsistant AppleScript
inconsistant AppleScript
- Subject: inconsistant AppleScript
- From: Jerrod Fowkes <email@hidden>
- Date: Thu, 25 May 2006 07:47:07 -0700 (PDT)
Hello all,
I have an applescript that I am calling from a Cocoa application. I need the ability to generate some of the script from code. A good portion of the applescript doesn't need to be generated so I am pulling it from a text file in my resource bundle and stuffing it's contents from a string. For now I am putting the whole script in the file to make sure that my hard coded values work and everything will be dandy. Well when I execute the script from Script Editor it works fine, and when I call the same script I am getting an error. I dump my string to the log and everything in the script is fine. The documentation says that I can put it into a string and it should be fine. Hrm.
The script interacts with iTunes. I know that some of the script works because I do a 'say "something"' in the first part of the script and I can hear that from my cocoa application. Further down the script I am constructing a path to a file to add to a playlist. The error dictionary says that the file doesn't exist when it does on the filesystem. When the script compiles and runs it doesn't appear that the engine is putting the root disk drive in my aliased path, when Script Editor does. the only thing that I can think of is that cocoa doesn't use the same engine that script editor does before the script is sent of to the Apple Event manager. I am guessing that there is something that I am not aware of.
Here is some code:
NSString* scriptString = nil;
scriptString = [[NSString alloc] initWithData: scriptData encoding: NSASCIIStringEncoding];
NSLog(@"%@", scriptString);
NSAppleScript* appleScript = nil;
NSDictionary* errorDict = nil;
errorDict = [[NSDictionary alloc] init];
NSAppleEventDescriptor* ae;
appleScript = [[NSAppleScript alloc] initWithSource: scriptString];
ae = [appleScript executeAndReturnError: &errorDict];
NSLog(@"%@", errorDict);
So basically I would think that you would be able to use both Script Editor and pass the same script into NSAppleScript as a string and it would work the same way. so, my question is why wouldn't it? -Jerrod
---------------------------------
Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2ยข/min with Yahoo! Messenger with Voice.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden