Online Book Reader

Home Category

AppleScript_ The Definitive Guide - Matt Neuburg [182]

By Root 1448 0
opinion. Some people profess to like them; I think they're the work of the devil. In part my opinion goes back to the days (Figure 20-1) when the only way to find anything in a dictionary window was through a scrolling list that clumped things into suites. You didn't know what suite anything was in, and the suites weren't listed in alphabetical order, so you could never find anything. Things are better now. I still don't know what suite anything is in, but I don't need to know, because Script Editor's dictionary has good searching. Best of all is Script Debugger's approach, where you can ignore suites altogether: the first column of the browser (Figure 20-6) lets you view commands, classes, records, and so forth without regard to suites.

Suites are also a kind of historical fossil. Back in the early days of System 7, even before AppleScript was made public, Apple Computer realized that if developers started freely adding Apple events to their applications and assigning them four-letter codes, there would be massive conflict and duplication of effort. Imagine a hundred different versions of the delete command, with a hundred different names and four-letter codes and sets of parameters; multiply that by the number of common commands and classes that scriptable applications were likely to need, and you can see the nightmare vision that was starting to unfold. So Apple created some standardized sets of commonly needed Apple events and classes, not telling developers how to implement them, but requesting them, where possible, to use Apple's choice of four-letter codes and English-like terminology, Apple's choice of classes and commands and parameters. The result was a centralized database—the Apple event registry . The suites resulted from this codification.

Interestingly, much of the Apple event registry contents still exist, as part of AppleScript—even though, ironically, most of the suites have fallen into disuse (see "The 'aeut' Resource," later in this chapter). Thus AppleScript itself contains, for example, a suite of Macintosh Connectivity Classes , with names like bus slot, which you can't see and which no application (as far as I know) has ever bothered to implement. On the other hand, certain suites present in AppleScript are quite commonly implemented, in whole or in part. The Standard Suite , sometimes referred to as the Core Suite , is the source of commands like exists, make, and select. The Text Suite, containing terms like word and text style info, is sometimes used as a starting point for applications that manipulate text. On the other hand, the Miscellaneous Suite , a frequent repository for commands like copy, cut, and undo, is a product of the Apple event registry but is not built into AppleScript itself.

You may recall that in Chapter 1 I said ("Is This Application Scriptable?") that the mere presence of a dictionary wasn't enough to prove that an application was scriptable. Apple's own Dictionary application, which I used as an example, essentially reflects in its dictionary the Standard Suite and the Text Suite from AppleScript itself. But this is really just a bug, a kind of automatic reflex of the framework used to build the application (basically, any Cocoa application that claims to be scriptable inherits this meaningless dictionary even if it isn't really scriptable).

A word needs to be said about the Required Suite . In the current implementation of AppleScript this is empty, but in the early days of System 7 these were the four Apple events to which every application, scriptable or not, had to respond in order to be System 7-native in the first place. That's because these were the fundamental messages sent by the Finder to do such basic things as launch and quit the application. The old Required Suite Apple events have been moved to the Standard Suite , and to this day, every application responds to them. They are shown in Table 20-1.

Table 20-1. The original Required Apple events

Command

Four-letter code

Effect

run

'aevt\oapp'

Launch the application

open

'aevt\odoc'

Open a

Return Main Page Previous Page Next Page

®Online Book Reader