Chapter 3. Building a Script from Scratch
So far, you’ve been on a quick tour of all the AppleScript stuff that comes with Mac OS X. You’ve learned how to add the Script Menu to your menu bar, how to use Script Editor, and even how to tweak one of the Script Menu’s scripts. Now, you’ll finally break free from the limits of your built-in scripts and start creating your own AppleScripts from scratch.
When most people refer to “scripting,” this is what they’re talking about: writing a new script all by themselves. With Script Editor as your trusty tool, you can link commands in the order you prefer, making it possible to create totally customized scripts to deal with the tasks you perform every day.
Before you can write the next blockbuster AppleScript, though, you first need to learn the basics. That’s what this chapter’s for: teaching you how to create your first simple script from the ground up.
The example scripts from this chapter can be found on the AppleScript Examples CD (see Sidebar 2.1 for instructions).
Just as you can’t surf the Web without a Web browser, you can’t create AppleScripts without a script-editing program. The aptly named Script Editor (in your Applications → AppleScript folder) is the simplest program for the job, but feel free to try any of the other editors listed on Sidebar 2.6.
Before you start diving into the following sections, the first thing you’ll need to do is launch Script Editor (Chapter 2). With this blank scripting slate before you, ...