Dyce & Sons Ltd.

Helping IT since 1993

Script Debugger 2.0

Thursday 28th December, 2000

If you’ve tried writing scripts in Script Editor, you’ll soon realise that figuring out where the bugs are can be a difficult proposition. AppleScript’s syntax, occasionally obscure use of variable coercion, and object model can make figuring out why a particular piece of code doesn’t work quite tricky. Is the syntax correct? Do I need to coerce that data? Is this piece of code being called at all?

Script Debugger 2.0 helps to get scripts up and running easily. Version 1.0.5 was a useful alternative to Apple’s Script Editor, enabling you to write and execute your code a line at a time. Stepping through your code, you could see your script in action, and what was happening to your variables along the way. There were limitations - you couldn’t see local variables within sub-routines, but it was great to use, because you were no longer restricted to scripts of less than 32K in length.

Version 2.0 is a complete rewrite. Late Night Software has written a new OSA scripting component called AppleScript Debugger. With the AppleScript Debugger component engaged, you’re provided with a script window and set of palettes that should be familiar to anyone who’s written code in a C compiler. The top of the window has three tabs - Description, Libraries and Debugging - with your script shown below.

The Debugging tab has two sub-panes. On the right is a list of all the variables so far discovered. As you compile a script, Debugger takes note of all your defined properties and lists them in this variable window. As your script executes and variables are defined, or their contents changed, they’re added to the list and flagged in red, making it easier to see where things are happening. Clicking the small diamond by the side of a variable marks it as a ‘watchpoint’ - if its value changes, execution pauses to let you look. Debugger now handles local variables. Too many variables to take in? There are checkboxes for you to show and hide both local and global variables. The left pane contains a list called Handlers (similar to a call stack in a C programming environment), showing you where you are in terms of nested sub-routines. Clicking on one of the handlers in the list takes you to that particular piece of code.

The script pane now supports split-pane editing, so you can view two or more sections of code at a time. Within a script, you can mark lines of code as ‘Breakpoints’- check the diamond by the side of a line, and execution of your script will pause when you get to it. Debugger supports several ways to execute your scripts: run, which runs until it hits a breakpoint; single-step, which steps through one line at a time, treating sub-routine calls as a single line; step-in, which follows execution into a sub-routine; and step-out, which runs to the end of the current sub-routine and pauses at the line after the sub-routine was called.

As your script executes, Debugger’s Apple Event Log lets you view and log Apple Events passing from the script, and the replies received from other applications. There’s an Apple Event dictionary browser for examining each scriptable application’s vocabulary, and an Object browser for viewing the application’s object model hierarchy.

But what really sets Debugger apart is the Explorer, which lets you directly view and edit the actual values for an open application. If you’re working in XPress, dragging an object from the Explorer to your script window results in a syntactically correct specifier for that object. The editor also has bracket and structure balancing, find and replace, and tool tips for expression values - point at an expression in the code and up pops a tooltip showing its value.

Debugger is also scriptable, recordable and attachable, with a Scripts menu and a palette for executing scripts within the editing environment (for example, scripts to create time out or try wrappers). There’s a Snippets palette for drag-and-drop access to your favourite AppleScript routines, and an Applications palette if you’re too lazy to type your own Tell statements. In all, Debugger makes debugging large scripts simple. The learning curve is very shallow, and it has a user interface Adobe would be proud of. What more could a scripter want?

Verdict

A script editor that makes scripting and debugging as simple and straightforward as it’s possible to be.

Get Further Info
Rating 4.5
Manufacturer Late Night Software
Pros No 32K limit ˜ Excellent debugging tools ˜ Scriptable, recordable, attachable
Cons Not yet OS X compatible
Price 189
Originally Published MacUser, Volume: 16, Issue: 24, p30