Date: Thu, 21 Sep 1995 20:03:57 EDT From: John Dowdell <71333.42@COMPUSERVE.COM> Subject: Re: Writing AppleScripts within DirectorGlenn Picher, on Sept 20, mentioned the need for AppleScript to reference a scripting dictionary resource in order to know what it can tell an app to do. Believe the further info requested is from this technote from the Knowledge Base. It's from November of 1993, and I haven't done much more with AppleScript myself since that time... hope it provides the requested background.
(I didn't understand the original question myself... almost sounded like the person wished to write AppleScripts within Director, but Lingo is not an Open Scripting Architecture environment as current HyperCard is.)
(A) As of Director 3.1.1.
AppleScript is a high-level implementation of AppleEvent transmission within a scripting language shell. It's most useful for system-level events, less useful as an application scripting language. As such, it complements Lingo well.
Apple's "Script Editor" application can create AppleScripts. It is available from Apple, or within "The Tao of AppleScript" by Derek Schneider & BMUG (the book, incidentally, is a good text on general scripting as well). Danny Goodman's "The Complete AppleScript HandBook" is more exhaustive, and is also recommended as a guide. There are also other scripting languages (Frontier, OmniScript, Mirror) that can make low-level AppleEvents easier to work with.
Director will respond to activate, tell, and "do script" commands sent from within the AppleScript Script Editor. With Director set to "Animate in background" this can happen in real time. Example:
tell application "Director 3.1.3"
activate
do script "set myObj = fileIO(mNew, \"?read\", \"TEXT\")"
end tell
Director can also activate pre-made AppleScripts that have been saved as
"run-only" applications, by using the standard Lingo "open" command. This is a
way to use the full range of AppleScript capabilities to communicate with other
programs.
Data can be transferred between applications via the clipboard. The Dartmouth Stack contains a "Clipboard XFCN" that works very well with Director 3.1. Clipboard operations are handled natively in Director 4.0. Note, though, that to successfully use the Mac Clipboard the application must be activated (ie, in the foreground).
AppleScript can automatically send "do script" instructions to any scriptable application. But to use Director's "evaluate" function to return the values of variables to AppleScript, the Script Editor would need to be told which AppleEvent corresponds to the word "evaluate" in a script. It receives this information through the use of a "dictionary", stored as a resource of type "AETE" in the resource fork of the application. Director 3.1.3 does not, unfortunately, possess such an AETE resource.
But there *is* a way to send both "do scripts" and "evaluates" to Director through AppleScript. This process is neither tested nor supported, but does seem to work quite well in v3.13. Procure a resource called "HyperAETE" from the scripting or HyperCard areas of various online services. This AETE table was put together by some good soul for HyperCard users. Using ResEdit, paste this resource into a copy of Director. Change the "WILD" designator within the ASCII section of the file to "MMDR."
This copy of Director will now be able to tell AppleScript that it can handle "evaluate" messages. If you open this dictionary within the Script Editor you will still see HyperCard references. Ignore these. Ignore, too, the "close docs" command...this is implemented in HyperCard, but not Director. The process does seem to work, however, and is potentially quite powerful.