AppleScript with invalid file name
AppleScript with invalid file name
- Subject: AppleScript with invalid file name
- From: "James J. Merkel" <email@hidden>
- Date: Sat, 3 Jul 2004 13:11:46 -0700
I'm trying to add scripting capability to my application.
To open a file (or a folder) I use the following (this not a document
based application):
- (BOOL)application:(NSApplication *)sender openFile:(NSString
*)filename{
BOOL isDir;
NSFileManager *manager = [NSFileManager defaultManager];
if( [manager fileExistsAtPath:filename isDirectory:&isDir] &&
isDir ){
if(batchWindowOpenFlag == FALSE){
[self parseDirectory:filename];
return YES;
}
else return NO;
}
else{
if( [manager fileExistsAtPath:filename] ){
NSLog(@"valid file %@\n", filename);
[ self openFile:filename];
return YES;
}
else {
NSLog(@"invalid file %@\n", filename);
return NO;
}
}
}
I have an AppleScript as follows:
tell application "PhotoInfo"
open file "users:jamesmer:KP140513copy.dcr"
delay 4
open file "users:jamesmer:junk"
end tell
The first file is a valid file, the second one is not.
If I run this script with PhotoInfo already running, everything works
as expected.
However if PhotoInfo is launched with this script then it (PhotoInfo)
crashes on the second file.
I thought this problem had something to do with PhotoInfo not finishing
launching -- hence I tried adding the delay 4 in the script. However
this didn't help.
Is there something else I should be doing in my Cocoa routine?
TIA,
Jim Merkel
_______________________________________________
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.