AppleScript_ The Definitive Guide - Matt Neuburg [14]
The Script Editor includes some facilities for helping you navigate and edit your scripts. At the top of the window, at the right side below the toolbar, is a popup menu for navigating among handlers (subroutines) within the script. The contextual menu that appears when you Control-click in the window gives access to various utility scripts that drive Script Editor itself (which is scriptable) to modify the text in useful ways. (You can edit these scripts, or add utility scripts of your own; they live in /Library/Scripts/Script Editor Scripts.) When the Script Assistant feature is turned on (in Script Editor's preferences), text is autocompleted as you type; press the Esc key to view or accept an offered completion.
Figure 2-2 shows an application's dictionary as displayed by the Script Editor. A dictionary contains (among other things) classes clumped into groups called "suites"; the dictionary window lets you navigate the resulting hierarchy. The figure illustrates two available navigation modes: you can use an outline at the left (front window) or a browser at the top (rear window). Here, the information for the disk class is being retrieved. Hyperlinks, a Back/Foward button in the toolbar similar to that of a web browser (rear window), and a Search field assist with navigation. The segmented button in the toolbar (rear window, left of the Print button) lets you display two further hierarchies in the browser: the containment chain (object model) and the inheritance chain.
Figure 2-2. A dictionary in Script Editor
Smile
Another free script editor application is Satimage's Smile. It provides an excellent working environment, including fine text-editing and navigation facilities, full scriptability, and some remarkable features to help you in developing scripts, including:
Execution of selected text
Automatic persistence of variables and readily accessible global context
Translation to raw four-letter codes (see Chapter 20)
Display of AppleScript's own dictionary (see Chapter 20)
Global terminology searching
Integrated facilities for constructing custom dialogs and displaying graphics
Script Debugger
A third alternative is Late Night Software's Script Debugger . This is a commercial program, but its features can easily justify the price if you're planning on doing any serious AppleScript development; this book could not have been written without it. Among other things, Script Debugger provides:
Display of script-level entity values
Display of values and Apple events in several formats, with browser windows for analyzing complex datatypes
Code coverage indication and timings
Debugging facilities such as breakpoints, stepping, tracing, and expressions
Superior dictionary display, with incorporation of inherited attributes, graphical class charts, and extensive cross-referencing
Display of actual attributes of running applications
Figure 2-3 shows a script paused at a breakpoint in debug mode in Script Debugger (Version 4). The column at the left shows the line where we are currently paused—actually two lines, because we are paused while a handler is being called—with lines that have been executed shaded blue (code coverage). The drawer at the right displays the datatype and value of the most recently executed statement, the handler call stack, and the values of all variables and top-level entities currently in scope (including AppleScript's own properties—see Chapter 16). A complex datatype (a list) is shown in hierarchical format, with icons indicating the owner of object references.