Script Debugger 4.0
When Apple was touting Automator as part of the OS X 10.4 Tiger upgrade, some people wondered whether AppleScript would be needed anymore. Now that we’ve seen Automator, AppleScript may be needed more than ever. There are holes in the way Automator works for those applications that support it, and there are plenty of applications that don’t support Automator at all.
Script Debugger 4.0.4, Late Night Software’s AppleScript editor, is a ground-up rewrite of what was already an excellent product. Although Apple includes an AppleScript editor with OS X, Script Debugger is much more than just an editor.
For one thing, Script Debugger includes its own version of the AppleScript OSA (Open Scripting Architecture) component, which gives you the sort of debugging controls you would expect in a professional programming environment—including the ability to see your code run one command at a time.
In addition, each Script Debugger script window has its own drawer containing a result box, a stack list (so you can see which AppleScript routines are currently being called), a variable viewer (for showing the current state of variables being used), an expression area (where you can construct debugging code that gets evaluated at every step), and an execution clock (which lets you know how long your script is taking to run). If a variable or expression changes between steps, the new value shows up in red, making it easier to see the effects your code causes.
At any stage when a script is running, you can select expressions within your code, place your cursor over the selection, and wait; a tool tip pops up, telling you what would happen if the selected code were to run. As you step through a script, the left-hand margin highlights to indicate which lines of your script have been executed. This feature makes it a cinch to find routines in old code that aren’t being run anymore.
The debugging process has also been improved. You can now debug more than one script at a time, so it’s possible to watch the interactions between scripts. Moreover, there’s a new option called break-on-exception, which pauses your script when an error occurs, so you can see the state of the script at the time of the error. And if you’re interested in the nuts and bolts of how your script is running, there’s a contextual menu item that lets you see which line of your AppleScript code produced a given Apple event.
Of course, debugging an existing script is one thing—writing one is quite another. AppleScript’s great strength is that each scriptable application extends the functions available to you. This power can be elusive, however, since it’s often a pain to figure out the correct syntax for a command or object reference. Luckily, Script Debugger has always excelled at this—and in version 4, it’s even better.
Using Script Debugger’s Dictionary window, it’s possible to view the commands and AppleScript classes that each scriptable application understands. The Dictionary can be viewed as both textual documentation (similar to Apple’s own Script Editor) and an object hierarchy (a graphical way of showing which objects can contain which other objects). You can search dictionaries, too, either via the Dictionary window or from a script window’s contextual menu. To make things even easier, dictionary entries are attractively laid out as HTML documentation and include hyperlinks so you can jump to the entries for related terms.
For a more dynamic version of an application’s dictionary, you can switch to the Explorer mode. This lists all current objects for the application in question—so if you were examining the Finder, for example, you’d see a list of each open Finder window, the picture being used as the desktop picture, the location of your Home folder, and other relevant Finder details. If you find an object you want to script, you can simply drag and drop it into your script to have Script Debugger write the code for referencing the object. That way, Script Debugger saves you from having to endlessly experiment to find the right syntax for what you’re trying to do.
But no update is without some problems. The Script palette is missing from this version, as is the script menu for easily running saved scripts. Worse still, Script Debugger 4 can no longer be scripted.
As some compensation for this, the Clippings feature has been enhanced; when you incorporate a clipping into your script (such as a skeleton for producing an if, then, else expression), Script Debugger can automatically incorporate selected code into the new expression. But sadly, script windows no longer support split views, so editing larger scripts can be a bit frustrating. (The company says this feature is planned for a future update.)
Macworld’s buying advice
Script Debugger 4.0.4 is almost everything an upgrade should be. Late Night Software seems to have taken every opportunity to condense and simplify Script Debugger’s interface, while providing easier access to powerful tools and better debugging information. If you’re serious about scripting, buy it.
[ Richard Dyce is a database consultant, journalist, and programmer in Elgin, Scotland. This review was published in the May 2006 issue of Macworld UK .]With Script Debugger, you can dig down into your stack list to examine AppleScript routines.Script Debugger’s Dictionary browser allows you to navigate through Suites, Commands, Events, Classes, Records, Enumerations and Types.
Script Debugger 4.0Next Page