AppleScript_ The Definitive Guide - Matt Neuburg [16]
Another internally scriptable application is Radio UserLand , the inexpensive "little brother" of UserLand Frontier (for our purposes the two programs are essentially identical). It's a multipurpose scripting program, typically used for creating web pages and for maintaining blogs. It stores scripts internally, and executes them; these scripts are usually in UserLand's own scripting language, UserTalk , but alternatively they can be written in AppleScript.
Figure 2-7 shows some AppleScript code being run in Radio UserLand. The AppleScript code is in the middle window—the one whose language popup, at the bottom of the window, is set to "AppleScript." (You should ignore the triangles at the left of each line, which are a feature of Frontier's outline-based script editing environment.) The UserTalk code in the bottom window calls the AppleScript code in the middle window and displays the result in the top window.
Figure 2-7. Radio UserLand
Script Runner
An application without facilities for editing or compiling scripts may nevertheless offer to execute compiled scripts for you on demand by way of some convenient interface, such as a menu . Such an application might be called a script runner . There is usually a requirement that a compiled script file be placed beforehand in some particular location where the script runner can find it. Because the script is compiled beforehand, a time-consuming step (compilation) is skipped, and execution typically proceeds considerably faster in a script runner than it does in an internally scriptable application where the code must be compiled from text on the fly.
Many scriptable applications act as script runners, typically by means of a special Script menu . This behavior is helpful because, having developed a script that drives such an application in a useful way, you might like some convenient interface for executing that script on future occasions; the application's Script menu provides such an interface. Scripts in an application's Script menu do not have to target that application, but the feature makes sense, and is provided, in the expectation that they will do so. (And when a script in an application's Script menu does target that application, there is sometimes a tremendous speed advantage over running that same script from elsewhere; see Chapter 22.)
For instance, as mentioned under "Customization" in Chapter 1, if you put scripts into ~/Library/iTunes/Scripts/, iTunes will generate a Script menu listing them and permitting you to run them; so that's a good place to store and access your scripts that customize iTunes.
BBEdit is a particularly fine example of a script runner. Whatever compiled scripts you place in ~/Library/Application Support/BBEdit/Scripts/ will appear as menu items in BBEdit's Script menu, where a script can be run by choosing its menu item. For even more convenient access, BBEdit lets you assign keyboard shortcuts to these menu items. BBEdit also implements some further conventions that have become a sort of de facto standard: you can edit a script by holding Option as you choose it from the Script menu, and you can reveal a script file in the Finder by holding Shift as you choose it from the Script menu. BBEdit also provides some useful naming conventions for setting the order of the items in the Script menu (otherwise the scripts would always appear in alphabetical order, because that's how the Finder supplies them); read the BBEdit manual to learn more. As an alternative interface, BBEdit also lists and lets you access scripts in a floating window.
Some other programs that act as script runners