AppleScript basics
14-Mar-94 21:54:03
Sb: #163922-AppleScript basics
Fm: John Baxter 71735,1626
To: Joe Sewell 74136,360
Joe,
In the recorded script, you get a comment (a full line comment). For
example (helping CIS along with the left chevron, as usual:
on JoeS ()
with objectModel, ToyStore
bringToFront ()
<< "New" menu command.
appleEvent (id, 'app1', 'nwin', '—-', "")
JWB comment: I seem to including a trailing <return>. I didn't remember
including that… Here's the AppleScript version of the same operation (in
both cases, switching an already-running ToyStore to the front, and selecting
the New command from the File menu:
tell application "ToyStore"
activate
(*"\"New\" menu command."*)
New Window ""
end tell
JWB comment: hmmm…I think I'll use typographic quotes next time. I'm not
sure where the blank line is coming from, using the "Copy Selected Script" menu
command on the Frontier version. There doesn't seem to be a return above (and,
there isn't a blank line in the Frontier script editor window
The C source won't mean much, although you can make a good guess based on the
function names
RecordOnlyString (kASAppleScriptSuite, kASComment,
"\p\"New\" menu command.");
return (RecordableString (app1class, 'nwin', "\p"));
No return character in there.
Actually, I believe an app can send an event to itself either in the special
way mentioned above (which is the way that gets things recorded, or via the
event queue. If the target address is a typePSN with the special value
kCurrentProcess, you get the direct dispatch form. I haven't had reason to try
to induce the AE Manager to do a slow self send via the event queue. A
typeSignature target address would probably do the trick.
"I wonder if that could get you in trouble, say if you were expecting it to
go through the event queue." Probably only once per developer.
–John