Last updated: 8/4/98


        1. AppleScript tells applications (and Scripting Additions, also known as "OSAXen") what to do.
        2. AppleScript is laid on top of OSA (Open Scripting Architecture), inter application communication (program linking) and high level Apple Events.
        3. Commands are also called events.
        4. The AOM (Apple Object Model) allows AppleScript to refer to objects (eg menu, file, word) in consistent syntax across various applications

        1. One language to control multiple applications.
        2. Part of the standard MacOS installation from version 7.5.
        3. Record actions across multiple applications.
        4. Consistent object model
        5. control remote applications, including multi processing across a network.
        6. Dictionary of events, objects and properties available in the applications.
        7. Can glue the best features of applications together - ie components.
        8. Automate repetitive tasks.
        9. Extendible via OSAX and scriptable applications.
        10. Simple language.
        11. Will be supported in Rhapsody.

What is a Script?
        1. A script is typed as text into the Script Editor, a FaceSpan interface object or other AppleScript editor.
        2. By clicking check syntax, the text is compiled into object code. English like commands are stored as Apple Events like: <<event data>>
        3. Because a compiled script is stored as object code, the dialect can be changed to another language like French, and the text code is redisplayed.
        4. A compiled script can be saved as an application called an applet. If an open handler is included in the script, the application will accept files being dropped onto it, so it is a droplet.

Scriptable Applications
Applications such as FileMaker, Finder, ClarisWorks can support AppleScript in three ways and to different levels.

A script can be written to control certain procedures and settings of the application. The application can be dropped onto the Script Editor to see its dictionary of understood commands, objects and properties.

An application can be Scriptable by just supporting the standard suite (open, close, print, quit), but that doesn't allow you to automate any useful operations. The Finder, FileMaker and Excel are among the most Scriptable applications. But they have limits. For instance, you cannot currently tell the Finder to log into a file server (without a scripting addition) and you can't tell FileMaker to define a new field. Other applications which are less Scriptable sometimes have work arounds by letting you call their in-built macros or menus. For example, you can create a macro in ClarisWorks, Word 6 or FoxPro and then AppleScript can "do script" to execute the macro.

When recording is turned on on the Script Editor, actions performed by the user in the application are written as AppleScript commands in the Script Editor's window.

An application must be scriptable to some degree before it can be recordable. If recordable, AppleScript can write a lot of your script for you as you simply use the application. For instance, with recording on, you can copy a file in the Finder, open it in Excel, parse it and save it, having the whole process recorded. A recorded script only contains commands. To really exploit AppleScript, you usually want to add parameter setting and getting and decisions (if then, repeat, etc) to make it more robust. Applications which are mostly scriptable include the Finder, Scriptable Text Editor, and many Internet client applications such as Fetch and Eudora. Excel 4, ClarisWorks, FileMaker, WordPerfect, HyperCard, Navigator and Explorer are scriptable but not recordable. There are many others.

Events in the application can be trapped to launch a script. For example, when the user chooses a menu, clicks an icon or moves a drawing a script can be activated.

Attachable applications are unfortunately rare and the level of support varies. Attachable applications include Finder, HyperCard, FileMaker 3.0, ClarisWorks Office 5 and FaceSpan. You can assign a script to an object like a button, icon or menu, executing once clicked, moved or whatever. You can save scripts as applications in the Finder so they execute when double clicked, or accessed somewhere in the Apple menu. HyperCard and FaceSpan allow you to assign scripts to buttons and just about every other interface object.

Editing Environments
There are several AppleScript editors on the market such as Script Editor (free with AppleScript from Apple), FaceSpan (which incorporates user interface building), Script Wizard, Script Debugger, and other non specialised applications which have some AppleScript editing support such as FileMaker 3.0.

Script Editors typically allow you to:
    1. View an application or OSAX dictionary.
    2. Turn recording on/off.
    3. Compile the script.
    4. Run the script.
    5. Show the result.
    6. Show the event log.
    7. Save as an application.
    8. Save as a read only application
    9. Open a non read only applet by dropping it onto the editor's icon.

AppleScript is part of the standard MacOS installation since 7.5 . It incorporates some Scripting Additions (OSAX). If you see redraw bugs with multiple styles in a script on PowerMacs, then you should trash the WorldScript Power extension. It can useful to install the AppleScript AppleGuide for quick reference. The FaceSpan extension is required to run FaceSpan mini applications or the FaceSpan application. AppleScript runs on any Mac. FaceSpan requires a 68020 or better. The Scriptable Text Editor comes as part of Speech recognition and some other packages.

An application's (or OSAX's) objects and events are shown in its dictionary in the Script Editor. To see an application's dictionary, just drop it onto the Script Editor icon.

Object Model
AppleScript uses the Apple Object Model to refer consistently to objects within applications. For example, to refer to a file in the Finder:

file "my file" of folder "big folder" of folder "small folder" of disk "my disk" of application "Finder"

or in the Scriptable Text Editor:

word 1 of paragraph 3 of document "my essay" of application "Scriptable Text Editor"

Objects exist in other objects and ultimately in an application. When referring to a series of objects within the same outer object, it is easier to wrap all the references inside a tell structure, eg:

tell application "Finder"
file "my file" of folder "big folder" of folder "small folder" of disk "my disk"
file "my other file" of folder "another folder" of disk "another disk"
end tell


tell folder "my folder" of disk "my disk" of application "Finder"
file "my file"
file "another file in same folder"
end tell

AppleScript commands are converted internally to high level Apple Events. Events are verbs or actions. Each application has its own suite of events which appear as plain text in the Script Editor Dictionary. Most applications have similar events such as delete, duplicate, make. AppleScript itself only has a few commands, and the most commonly used is set. The complete AppleScript Syntax is listed here.

User Interface
An AppleScript script has almost no user interface (buttons, menus etc) but uses little memory for a basic program and can interact easily with many applications, even on another networked Mac.

If a user interface is required, then you can use an OSAX, such as display dialog, tell an application to display some text or buttons (if the application supports those actions), or build the application in an GUI editor such as FaceSpan or HyperCard.

In FaceSpan, you can create windows, menus, buttons etc all with associated scripts. You can add in OSAXen, pictures, movies and so on. It has some quite sophisticated elements like tables (like a spreadsheet) and drag-and-drop support. You can create a standalone application and distribute it royalty free.

Return to Parent Folder