Saving a Script
Before you save a script, let Script Editor check its syntax by clicking the Compile button. (If you don’t perform a syntax check manually before trying to save, Script Editor will automatically do it for you as soon as you try to save.)
Note
The Compile button won’t find any errors if you created a script using the “watch me” system. After all, Script Editor itself wrote the script, so of course it’s perfect. But when you write scripts by hand, as described later in this chapter, you’ll find the Compile button a useful tool for cleaning stray errors out of your scripts.
If Script Editor finds your script to be correctly written, you’ll get no reaction from Script Editor except to see your script formatted with colors and fonts, as shown in Figure 7-3. If it does find a problem with the syntax, you’ll be limited to saving your script file in only one format: plain text.
Figure 7-3. If you type an AppleScript manually, it appears just as it would in a word processor (top left): in Courier with no special formatting. When you click the Check Syntax button, however, Script Editor indents the tell block and changes all type to Verdana (bottom right), with AppleScript’s reserved words (language keywords and application keywords) in colored type and comments in smaller, italic type. Congratulations: You’ve got the Script Editor seal of approval.
At this point, you’re ready to ...
Get Mac OS X: The Missing Manual, Panther Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.