AppleScript_ The Definitive Guide - Matt Neuburg [175]
tell application "Finder"
get text item delimiters -- error: Finder got an error: Can't get text item delimiters
end tell
In that code, AppleScript successfully resolves text item delimiters as the 'txdl' property, but then it makes a mistake: it sends an Apple event to the Finder, asking for this property. The Finder has no 'txdl' property, so it returns an error. The usual workaround is to add my or AppleScript's:
tell application "Finder"
get my text item delimiters -- fine
end tell
But no Apple event is sent to the Finder in the case of a one-word global property:
tell application "Finder"
get space
end tell
I believe this is the same behavior discussed in "No Terminology Clash," earlier in this chapter: space is a name already in scope, and we don't say this is the Finder's space, so it is assumed to be our space (meaning AppleScript's space). Evidently this rule breaks down with multiple-word properties. Fortunately, multiple-word properties that you might be tempted to use unqualified (without saying of something) are very rare—indeed, text item delimiters is probably the only one.
What's in a Dictionary
Dictionaries are not presented to you as a verbal explanation with instructions for their use. They are structured in tabular form and typically displayed through a special dictionary viewer window within a script editor application. It takes time and practice to learn to use this dictionary viewer and to get the most out of its display . You need to be adept at reading and understanding a dictionary display if you are to communicate successfully with scriptable applications and scripting additions.
The good news is that, starting in Tiger, the Script Editor 's dictionary display has been improved (for the first time since the dawn of AppleScript). Back in the bad old days, the dictionary was shown in a simple, primitive way (Figure 20-1). Its table of contents was a simple scrolling list down the left side, organized by "suites" that were not alphabetically arranged. Because you didn't know what "suite" a particular item was in, you had to scroll through the list looking for it in each suite. Clicking an entry in the list displayed its information in the main pane; that information was static and terse.
In Tiger, the list on the left is an outline whose headings can be opened and closed; alternatively, you can use a columnar browser at the top of the window (Figure 20-2). A search field at the top lets you jump directly to a desired entry. The information for an entry is more copious: you learn not only what elements a class contains but also what classes it is an element of. And class names are hyperlinks, which you can click to jump to their entries and read their information.
In Script Debugger , the dictionary display is even better. (See Figure 20-3; the screenshot has been doctored to shorten the window by omitting some of the elements.)
The columnar browser at the top of Script Debugger's dictionary window has categories grouping commands and classes, letting you escape the tyranny of "suites." In the information displayed for an entry, the plural is given; properties and elements are shown in a clean, tabular layout; all datatypes (not just classes) are hyperlinked; and an extra section at the bottom of the display lists all classes of which this is an
Figure 20-1. The dictionary display in Script Editor 1.8.3
element or property and all verbs of which this is a parameter type. There is also an option, not shown here, to display the raw four-letter codes in addition to their English-like translations. (I'll talk about further features of the Script Debugger dictionary display later on.)
Not only the dictionary display has been improved; starting with Tiger, applications can take advantage of a new dictionary format. In the past, an application expressed its dictionary as an 'aete' resource; starting in