Re: NSAppleScript error that is not an error
Re: NSAppleScript error that is not an error
- Subject: Re: NSAppleScript error that is not an error
- From: Nathan Day <email@hidden>
- Date: Wed, 18 Jun 2003 17:20:11 +0930
Try changing the newlines '/n' to returns '/r', this might fix it.
On Wednesday, June 18, 2003, at 08:52 AM, Mark Steinberg wrote:
I am executing an apple script using NSAppleScript. The code looks
like this:
+(void) makeAliasForPath:(NSString *)thePath andNameIt:(NSString
*)theAliasName
{
NSLog(@"Make alias for path = %@", thePath);
NSAppleScript *theScript;
NSDictionary *errorDict;
NSString *theSource2 =[NSString stringWithFormat:@"tell application
\"Finder\"\nset thePath to POSIX file \"%@\"\nset theAlias to make new
alias file at desktop to thePath\nset the name of theAlias to
\"%@\"\nend tell\n", thePath, theAliasName];
NSLog(theSource2);
theScript = [[NSAppleScript alloc] initWithSource:theSource2];
[theScript executeAndReturnError:&errorDict];
NSLog([errorDict description]);
}
It returns an error every time and yes, the path is valid. The NSLog
output looks like this:
2003-06-17 18:15:38.225 MakeAlias[5289] Make alias for path =
/Volumes/Monster/Applications/Acrobat Reader 5.0
2003-06-17 18:15:40.978 MakeAlias[5289] tell application "Finder"
set thePath to POSIX file "/Volumes/Monster/Applications/Acrobat Reader
5.0"
set theAlias to make new alias file at desktop to thePath
set the name of theAlias to "AAAAlias"
end tell
2003-06-17 18:16:07.452 MakeAlias[5289] {
NSAppleScriptErrorBriefMessage = "Can't make a alias file.";
NSAppleScriptErrorMessage = "Finder got an error: Can't make a
alias file.";
NSAppleScriptErrorNumber = -2710;
NSAppleScriptErrorRange = <00000077 00000029 >;
}
if I select the dump of the Applescript above and paste it into
ScriptEditor I get exactly the same error when I execute it. Here's
the catch. If I select any character in the script within ScriptEditor
and retype that character, the script executes properly without error.
Any help will be greatly appreciated.
Nathan Day
http://homepage.mac.com/nathan_day/
_______________________________________________
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.