DekGenius.com
[ Team LiB ] Previous Section Next Section

Chapter 19. Dictionaries

A dictionary is a scriptable application's way of letting the world know how it extends AppleScript's vocabulary. This extended vocabulary is called the application's terminology. AppleScript itself defines few commands, and has few abilities of its own; its value emerges when it is used for communicating, by means of Apple events, with scriptable applications. A scriptable application provides powers that AppleScript lacks, along with terminology that permits the programmer to harness those powers. For example, AppleScript can't make a new folder on your hard drive, but the Finder can; and the Finder supplements AppleScript's vocabulary with terms such as make and folder so that you can use AppleScript to command it (the Finder) to do so. This supplementary terminology is made available through the Finder's dictionary.

A dictionary has two intended audiences:


The AppleScript programmer

The AppleScript programmer studies a human-readable display of an application's dictionary to learn what English-like terms beyond those built into the AppleScript language itself may be used when targeting that application.


AppleScript

AppleScript uses an application's dictionary at compile time to look up the terms that the programmer uses. In this way, AppleScript confirms that the terms really exist; since they don't exist within AppleScript itself, AppleScript cannot know without a dictionary that the programmer isn't just talking nonsense. AppleScript also uses the dictionary to resolve the terms into their corresponding Apple event form; otherwise, AppleScript wouldn't know what actual Apple event messages to send to the scriptable application at runtime. And it uses the dictionary when decompiling, to translate those Apple event terms back into English-like form for display to the programmer.

This chapter discusses both aspects of dictionaries. It explains how AppleScript uses dictionaries. It also describes the dictionary as experienced by the programmer, who will use it to learn how to talk to an application. Studying a dictionary to figure out how to use AppleScript to get an application to do your bidding (and combining that study with experimentation when the dictionary is insufficiently informative) is a major part of the typical AppleScript programming experience. See Chapter 3 for an example.

Certain details about how an application's dictionary is stored appear in Section 4.8. In Section 10.2 we talked about how AppleScript decides what application it will be sending Apple events to. In Section 12.3 and Section 12.4 we discussed how AppleScript decides what application's dictionary it will use to resolve terminology.

    [ Team LiB ] Previous Section Next Section