AppleScript_ The Definitive Guide - Matt Neuburg [177]
For example, in the Finder's dictionary, the disk class's format property is specified as an enumeration called an 'edfm'. That enumeration is defined elsewhere as having enumerators including Mac OS Extended format, audio format, and so on. So the actual value will be Mac OS Extended format or some other member of the list. In BBEdit, the close command's saving parameter is a 'savo' enumeration. That enumeration is defined elsewhere as having enumerators yes, no, and ask. So you are expected to supply yes, or no, or ask as the value of this parameter.
In the Script Editor's display of a dictionary, enumerations are not listed along with classes. Rather, an enumeration is shown as a value type by listing its enumerators (separated by slashes). In Figure 20-2, the format property is not said to be a certain kind of enumeration; instead, a list of that enumeration's enumerators is displayed. Similarly, in the Script Editor's display of BBEdit's dictionary, the close command's saving parameter is not said to be a certain kind of enumeration; its value is given as yes/no/ask, a list of that enumeration's enumerators. This way of displaying an enumeration rapidly becomes all but illegible as the number of enumerators increases (as Figure 20-2 demonstrates). Also, enumerations and enumerators may have comments describing their meaning and usage; this information is completely stripped from the display.
Script Debugger's display is much more like what's actually in the dictionary. Enumerations are listed separately in tabular form, showing their enumerators and any comments. A property or parameter whose value is an enumeration gives the enumeration as a hyperlink; you click the hyperlink to see the listing of its enumerators.
In your code, when you supply a value that is stated in the dictionary to be an enumeration, the AppleScript compiler does not check to see whether that value is in fact an enumerator of the specified enumeration.
Classes
A class is a datatype (see Chapter 13). Applications are free to define new datatypes in addition to those provided by AppleScript. These will generally correspond to the various types of thing the application operates on. For example, the Finder is all about files and folders on disks, so it has a file class, a folder class, and a disk class.
Internally, the dictionary expresses a class as a four-letter code. Where a class is already defined by AppleScript, the dictionary uses (or should use) the same four-letter code that AppleScript uses. In the dictionary display, you will see the English-like name of the class. (See "Value Types," earlier in this chapter.)
Plurals
For most classes, the dictionary will provide both a singular and a plural form for the English-like term. So, for example, the Finder defines both file and files, both folder and folders, both disk and disks. In the Script Editor's display of the dictionary, a class's plural appears when that class is listed as an element of another class (Figure 20-2). In Script Debugger, the plural is given explicitly along with the class's name (Figure 20-3).
The AppleScript compiler uses this information to treat singular and plural alternatives with some intelligence (see "Nonsensical Apple Events," earlier in this chapter). For example, a bare plural is often interchangeable with every plus the singular: you can tell the Finder equivalently to get disks or to get every disk. This is not because AppleScript has any natural-language intelligence; it's because the dictionary explicitly says that disks is the plural of disk.
Sometimes, a dictionary won't provide a plural form for a class name. Perhaps there is only one object of that class (it occurs only as a property, not an element).