Re: AppleScript create command
Re: AppleScript create command
- Subject: Re: AppleScript create command
- From: "James J. Merkel" <email@hidden>
- Date: Mon, 12 Jul 2004 09:06:43 -0700
I'm writing my own create command and have made some progress, but
have run up against a roadblock.
At present I have an AppleScript as follows:
tell application "PhotoInfo"
set tFilePath to alias ":Users:jamesmer:temp-71.jpg"
extract new metadata from tFilePath
get date and time of metadata 1
end tell
I get the following output on the console:
2004-07-12 08:44:45.920 PhotoInfo[11135] Suite NSCoreSuite, apple event
code 0x3f3f3f3f
2004-07-12 08:44:45.926 PhotoInfo[11135] Suite NSTextSuite, apple event
code 0x3f3f3f3f
2004-07-12 08:44:45.992 PhotoInfo[11135] Suite PhotoInfo, apple event
code 0x50496e66
2004-07-12 08:44:46.110 PhotoInfo[11135] Command: PhotoInfo.InitExifInfo
Direct Parameter: (null)
Receivers: (null)
Arguments: {FileName = "/Users/jamesmer/temp-71.jpg"; ObjectClass =
1165519206; }
2004-07-12 08:44:46.149 PhotoInfo[11135] numberOfLines = 38
2004-07-12 08:44:46.164 PhotoInfo[11135] Result: <NSIndexSpecifier:
metadata 1>
2004-07-12 08:44:46.255 PhotoInfo[11135] Command: NSCoreSuite.Get
Direct Parameter: <NSPropertySpecifier: dateTime of metadata 1>
Receivers: <NSPropertySpecifier: dateTime of metadata 1>
Arguments: {}
2004-07-12 08:44:46.258 PhotoInfo[11135] Result: (null)
2004-07-12 08:44:46.258 PhotoInfo[11135] Error: 8
"NSInternalScriptError"
The PhotoInfo.scriptSuite file in ASCII form is:
{
AppleEventCode = PInf;
Classes = {
ExifInfo = {
AppleEventCode = Exif;
Attributes = {
dateTime = {AppleEventCode = Dtim; Type = NSString; };
makeString = {AppleEventCode = Make; Type = NSString; };
modelString = {AppleEventCode = Modl; Type = NSString;
};
};
Superclass = "NSCoreSuite.AbstractObject";
SupportedCommands = {"PhotoInfo.InitExifInfo" =
"handleInitializeExifCommand:"; };
};
NSApplication = {
AppleEventCode = capp;
Superclass = "NSCoreSuite.NSApplication";
SupportedCommands = {"PhotoInfo.InitExifInfo" =
"handleInitializeExifCommand:"; };
ToOneRelationships = {metadata = {AppleEventCode = Exif;
Type = ExifInfo; }; };
};
};
Commands = {
InitExifInfo = {
AppleEventClassCode = PInf;
AppleEventCode = inEx;
Arguments = {
FileName = {AppleEventCode = iExi; Type = NSString; };
ObjectClass = {AppleEventCode = kocl; Type =
"NSNumber<TypeCode>"; };
};
CommandClass = NSScriptCommand;
ResultAppleEventCode = "obj ";
Type = NSScriptObjectSpecifier;
};
};
Name = PhotoInfo;
}
The PhotoInfo. scriptTerminology file is:
{
Classes = {
ExifInfo = {
Attributes = {
dateTime = {Description = "The date and time of the
image"; Name = "date and time"; };
makeString = {Description = "The make of the camera";
Name = make; };
modelString = {Description = "The model number of the
camera"; Name = model; };
};
Description = "metadata is a class that provides
information from Digital camera files.";
Name = metadata;
PluralName = metadatas;
};
NSApplication = {
Description = "PhotoInfo's top level scripting object.";
Name = application;
PluralName = applications;
};
};
Commands = {
InitExifInfo = {
Arguments = {
FileName = {Description = "The file to open should
follow, quoted"; Name = from; };
ObjectClass = {Description = "The name of the class";
Name = new; };
};
Description = "create a metadata object";
Name = extract;
};
};
Description = "PhotoInfo specific classes and commands.";
Name = "PhotoInfo Suite";
}
The handleInitializeExifCommand: is as follows:
-(id)handleInitializeExifCommand:(NSScriptCommand *)command{
unsigned int numberOfLines;
ExifInfo * infoBlock = nil;
NSDictionary *args = [command evaluatedArguments];
NSString *file = [args objectForKey:@"FileName"];
infoBlock = [[ExifInfo alloc] initWithFile:file];
[infoBlock setThumbnailStart:0];
[infoBlock setThumbnailLength:0];
if([infoBlock isImageFile]){
numberOfLines = [infoBlock extractExifInfo:file];
NSLog(@"numberOfLines = %d\n" ,numberOfLines);
return [infoBlock objectSpecifier];
}
else{
[infoBlock release];
return nil;
}
}
And the objectSpecifier is as follows (copied from previous posts on
similar topics):
- (NSScriptObjectSpecifier *)objectSpecifier {
NSScriptObjectSpecifier *containerRef = [NSApp objectSpecifier];
return [[[NSIndexSpecifier alloc]
initWithContainerClassDescription:[containerRef
keyClassDescription] containerSpecifier:containerRef key:@"metadata"
index:0] autorelease];
}
As shown in the console output, I am not able to use the AppleScript
object in a get statement.
Also, I notice in Script Editor that I get: +class ; 1 shown after
running the extract command. Not sure this is correct.
Anyone see what is wrong with what I have done?
Thanks,
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.