Elements and Properties

Two other very important characteristics of Apple event objects are elements and properties. The class that these objects are based on defines the object’s elements and properties. An object has zero or more of its defined elements, and exactly one each of its properties.

For example, SoundJam™ MP, a digital music player and encoder, defines a playlist window class. These objects are windows that contain lists of audio tracks that can play on the computer. Figure 1-6 shows the definition of the playlist window class from SoundJam’s dictionary. (Chapter 2 explains a program’s dictionary, which can be viewed by using Script Editor’s File Open Dictionary menu command.) A playlist window object has three elements: track, file track, and URL track. Further, playlist windows have a modified property (a true or false value depending on whether the window was modified since it was last saved). playlist windows also inherit several properties from SoundJam™ MP’s window class. So a playlist window object can contain zero or more “track” elements, but it only has exactly one “modified” property value.

playlist window’s elements/properties
Figure 1-6. playlist window’s elements/properties

Rest assured that it is easy to grab the values of elements and properties in AppleScript. You can use syntax such as:

tell app "SoundJam™ MP" to get first file track of first playlist window

This code sends SoundJam™ a ...

Get AppleScript in a Nutshell 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.