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
|Get Further Info|
|Pros||Search & Replace + Scriptable|
|Cons||No debugging OSA component|
|Originally Published||MacUser Volume 19, Issue 4|