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: Alan Woolman <email@hidden>
- Date: Wed, 18 Jun 2003 10:13:25 +0200
set thePath to POSIX file "/Volumes/Monster/Applications/Acrobat Reader
5.0" returns
":Volumes:Monster:Applications:Acrobat Reader"
There are two problems:
1. The first semi-colon will produce an error
2. The Finder doesn't recognize "Volumes".
This works (at least OMM):
tell application "Finder"
set thePath to POSIX file ("Applications/Acrobat Reader 5.0") as string
set myDrive to "Monster"
set newPath to myDrive & thePath
set theAlias to make new alias file at desktop to file newPath
set the name of theAlias to "AAAAlias"
end tell
I'm not an AS expert, so there may be a simpler way.
On Wednesday, Jun 18, 2003, at 07:00 Europe/Zurich,
email@hidden 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.
Mark
Alan Woolman
--
Harold's Hamburgers & Cyber Cafi
Place Centrale, case postale 211
1936 Verbier, Switzerland
tel: +41-27-7716243, email: email@hidden
web:
http://www.harolds.ch
_______________________________________________
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.