Constructing an Apple Event

Hi all,
I’m having a hard time figuring out the proper direct object and parameters to send in an AESend call to get iSync to send back its status.

I can tell that the actual “sync status” command in iSync is the ‘stsy’ event ID, and the ‘getd’ event ID is the generic Get Data event, but I do not know where the other of the four elements come into play.

I just want to construct an AppleEvent to send with AESend, waiting for a reply, and the event I want to send is the ‘stsy’ command.

I have the basic AppleEvent done - with the address descriptor, and that works fine as long as all I am sending is a single EventClass and EventID pair like ‘blrn\SYNC’, with no parameters.

Can anyone help me figure out which is the direct object and if I send all four of these keyworded pairs as parameters? I have read 100 pages of the developer documentation and nowhere can I find these keys ‘form’, ‘want’, or ‘seld’. I also can’t find what the ‘csig’ keyword means, and if I need to send it, and if so, how.

I just want to do a Get Data on the Property ‘stsy’, but these other things have me stumped.

I am thinking that the EventClass and EventID are ‘core’'getd’, and the direct object is a list of the four parameter pairs listed below. Is this right?

Here is what Script Editor sends when the “sync status” command is sent in a tell block to iSync:

‘core’'getd’{
‘----’:‘obj ‘{
‘form’:‘prop’,
‘want’:‘prop’,
‘seld’:‘stsy’,
‘from’:’‘null’’()
},
&‘csig’:65536
}

‘----’ = keyDirectObject, an Apple event parameter key.

'obj ’ = typeObjectSpecifier; an object specifier. See the section on object specifiers in Inside Macintosh: Interapplication Communication for more information.

‘csig’ = enumConsidsAndIgnores, an Apple event attribute key. This one is only needed for specifying case/diacritical/whitespace/etc. sensitivity in commands that understand this attribute (hardly any in practice). Just ignore it.

See also the AE.framework and OpenScripting.framework headers.

If you’re sending events from ObjC, I’d suggest using objc-appscript:

ISApplication *iSync = [[ISApplication alloc] initWithName: @"iSync"]; NSNumber *status = [[[iSync syncStatus] get] send]; [iSync release];
If you’re sending events from C, easiest would be to use AEBuildAppleEvent. The syntax for the parameter format string is basically the same as displayed by AEDebug, so it’s pretty much a copy-n-paste job:

[code]DescType creator = ‘iSnc’;
AppleEvent event, reply;
OSStatus err;

err = AEBuildAppleEvent(
‘core’,
‘getd’,
typeApplSignature,
&creator,
sizeof(creator),
kAutoGenerateReturnID,
kAnyTransactionID,
&event,
NULL,
“‘----’:'obj '{‘form’:‘prop’, ‘want’:‘prop’, ‘seld’:‘stsy’, ‘from’:‘null’()}”,
);

err = AESendMessage(&event, &reply, kAEWaitReply, kAEDefaultTimeout);[/code]
HTH

Thanks so much! I’ve been struggling with this for a week now.

It works perfectly!!

I figured out by trial and error how to extract the returned long integer from iSync:

err = AEGetParamDesc(&reply, keyDirectObject, typeWildCard, &desc);

err = AEGetDescData(&desc, &result, 8);

return result;

And, sure enough, the result is the long integer 5, exactly as it should be!!

Thanks a lot … I am indebted to you!!

Johnny