Using Tiger: Learning AppleScript
This article is excerpted from The Mac OS X Tiger Book from Wiley Publishing (0-7645-7956-6); the book can be ordered from Amazon.com and Barnes & Noble. Copyright ©2005 by Wiley Publishing, Inc. This material is used by permission of John Wiley & Sons, Inc.
Alternatively, you can click File: New.
The Stop button activates.
Create those four windows, click in them until they’re displaying the folders I want to examine, and change their views to the styles I want (one set to Columns and the rest set to Lists).
Notice that the script window is now jam-freakin’-packed with script.
The final result is what you see below.
Woo-hoo! Just imagine having to type all that in yourself! Recording scripts rules!!!
Not so fast, Skeezix. Why don’t you try something even simpler, like recording all the steps of using the Finder to connect to an FTP server? Go ahead. I’ll wait here.
Uh-huh. You wound up with something like the screenshot below, didn’t you?
The only thing it actually recorded was that thing at the very end, when you finished logging in to the FTP server and you changed the window’s view from Icon to List. See what I mean? Spotty and unpredictable. Recording scripts isn’t totally useless, but once you pick up some scripting skills, you practically never use it.
Well, the Finder window thing went well at any rate. I might want to actually use that script later. Which dovetails us nicely into…
Saving a script has a couple of quirks, compared to saving document files in other applications. No big surprise…in a sense, you’re building software here, so you have to decide how this new software is going to be deployed, you know? The screenshot below shows Script Editor’s standard Save dialog.
Script Editor’s Save options
The file format options are as follows:
* No, really… I want to know about Bundles : I’ll give you the simplest possible explanation of what a Bundles is—it’s a scheme that the Mac OS uses to ensure that a price of executable software and its resources are always lumped together and treated like a single entity. Imagine that I’ve written an AppleScript that takes a generic, prefabbed sales agreement (which exists as a TextEdit document) and, after asking the user some questions, prints out a binding contract that even Judge Judy would approve of. It’s so useful that I want to give it away to people. If I save the script as a bundle, I can stick the template file right in the same package as the script. My script will always be able to find it, and there’s no chance that someone will receive this script without this Really Important File. Bottom line is that Bundles are things you’ll deal with as you become an advanced scripter. Don’t worry about ’em for now. These aren’t the droids you’re looking for. Move along.
You also have three options available to you:
Give the script a name, click Save, and you’re golden.