What’s in a Dictionary
This section describes the contents of a dictionary. This is primarily so that you can interpret a dictionary when you read it in an application such as the Script Editor.
Enumerations
An enumeration is a value that must be one of a fixed list of four-letter codes. These four-letter codes are called enumerators ; and the enumeration itself also has a four-letter code, identifying the entire set of its enumerators. Thus, by using the four-letter code of an enumeration, a dictionary can specify that a value must be one of the enumerators of that enumeration.
For example, BBEdit’s dictionary entry for the
close
command reads, in part:
close reference [saving yes/no/ask]
The triad of values yes/no/ask
is an enumeration.
The dictionary actually just says here that the
saving
parameter is a 'savo
‘.
That’s the four-letter code for an enumeration. The
script editor application, presenting this information in
human-readable form, has looked up the 'savo
'
enumeration in the dictionary and has fetched the English-like
equivalents of its three enumerators. The four-letter code for the
enumeration itself, 'savo
', has no English-like
equivalent.
By and large, an enumerator is the same thing as a constant, as
discussed in Chapter 17. If you ask AppleScript for
the class of yes
, it tells you
it’s a constant
.
AppleScript uses this information to translate between English-like terms and four-letter codes, but the compiler does not check to see whether the value you actually supply ...
Get AppleScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.