Dyce & Sons Ltd.

Helping IT since 1993

Script Editor 2

Friday 14th February, 2003

AppleScript allows you to write English-like scripts to control various applications on your Mac. However, you may have found Apple’s scripting tool, Script Editor, a little lacklustre - even when it moved to Mac OS X. However, Apple has now released the preview version of Script Editor 2, which has a number of useful additions that make the creation of scripts easier and quicker.

There are other script editors for AppleScript out there - notably Late Night Software’s ScriptDebugger - and, as usual, instead of taking on the third-party guys on their strengths, Apple has chosen simply to raise the baseline. It isn’t just the interface that’s been overhauled, although it does sport one of those charming drag-and-drop customisable Aqua toolbars. There are now three main additions to its editing features. It has multiple undos, a standard search-and-replace dialog, and auto-wrapping of long AppleScript statements. All very obvious stuff, but their absence has long been a thorn in the program’s side.

Version 2 has a contextual menu containing a number of shortcut items that can be used to add particular AppleScript constructs to your scripts, which will be a boon to novice scripters. Holding down the control key (or right-clicking if you have a two-button mouse) offers you a pop-up menu of 10 hierarchical submenus, ranging from Repeat Routines, through Dialogs, to Action Clauses and Folder Actions.

Each item on a submenu adds a generic script element, such as a structured repeat clause, including appropriate comments so that you can figure out what you need to add and where. As well as being a great aide memoire, it’s also a useful instructional tool. It will show you how to construct more complicated repeat statements that have special cases for the first and last iterations. This functionality is a direct lift from ScriptDebugger and the implementation of this has been copied as well: finally Apple has produced a scriptable script editor.

Each item on the contextual menu is a script in its own right, and you can broaden the menu by adding scripts and folders containing scripts to a folder inside the Library folder. Once you have the hang of scripting, you can simplify your own scripting process by creating your own contextual scripts, geared to the way in which you work.

Window of opportunity

As well as the whizzy interface, Script Editor has also seen some window dressings. Both the Result and Events windows are now tied to a particular script, and the information area is now an Aqua-style drawer. You also have two new history windows for events and results so you can revisit the results of the last few runs of a script and compare the’before and after' of a change to an existing script. This new version of Script Editor isn’t a direct replacement for either Apple’s AppleScript Studio or for third-party products such as ScriptDebugger. While it can use OSA components such as the built-in JavaScript, it doesn’t include the powerful ScriptDebugger AppleScript component, so you can’t use it to step through code line by line - debugging scripts in Script Editor 2 can still be laborious. However, if you’re considering writing AppleScripts, it could make your first steps a little easier.

Get Further Info
ManufacturerApple
ProsSearch & Replace + Scriptable
ConsNo debugging OSA component
PriceFree
Originally PublishedMacUser Volume 19, Issue 4