Applescript Stands Alone

AppleScript need not depend on other applications. For very simple tasks, AppleScript can be used for self-contained applets. For instance, the code below brings up a modal dialog box requesting that the user enter a number (in inches) in the space provided (default answer). This number is then converted to pixels using the Macintosh standard of 72 pixels per inch. A second dialog box is then brought up displaying the result. No other application is involved.

set pix to 72
set answer to text returned of (display dialog "Enter in the number of inches" default answer "1")
display dialog answer & "in = " & (answer * pix) & "px"

AppleScript Studio, XCode, and OS X

With Mac OS X, AppleScript has grown well beyond its humble beginnings. AppleScript Studio is a development environment, which comes bundled with Mac OS X. It uses AppleScript as the primary programming language and in conjunction with the Cocoa framework can construct a full-fledged graphical user interface for the application.

With Mac OS X v10.3 (“Panther”) AppleScript Studio and Project Builder were rolled into the Xcode IDE. Interface Builder, another component of Xcode, lets you build a user interface in a drag-and-drop fashion (similar to Visual Basic) and then “run” the user interface to see what the forms and menus looks like.

Panther and Tiger (OS X 10.4) also come with an enhanced version of Script Editor, the minimalist editor for compiling and running AppleScripts. One new feature of this editor is that if you right-click (or control-click) on the editing area, you get a pop-up menu with a large range of options for script fragments to paste into your code. This is an excellent feature for people learning to write AppleScript. From that menu, you can also open up the directory where these scripts are kept, and have a look at them. You can also add your own scripts (although you need to restart Script Editor for these changes to show up in the pop up menu).