References to objects
A command requires at least one object. If you don't specify an object, AppleScript uses a default object, which is usually the active application. You can specify the default object for commands by using a Tell control statement. To identify the objects of a command, you use a reference. The following phrase is a reference: the comment of file "Picture 1" of desktop A reference provides this information to identify an object: In the example, the class of the object is "comment" while the container is a series of containers: a file located on the desktop. The name "Picture 1" identifies a specific file. AppleScript provides several ways to reference objects. Here are some of the forms you can use. Name: close document "Report" Index: word 2 of paragraph 3 Positive numbers indicate the position from the beginning of the container; negative numbers from the end. You can use keywords such as first, second, and third, or write the numbers like this: 1st, 2nd, 3rd. second word of third paragraph 2nd word of 3rd paragraph You can use these keywords: last, front, back. last word of third paragraph Property: name of front window ID: id of disk "Hard Disk" Every: every word of "That's all folks." You can use the plural form of the name instead: words of "That's all folks." The resulting value of this reference is a list of the words. Filter: every file in control panels folder whose file type is "APPL" The part beginning with "whose" defines the condition. This is a Boolean expression that is either true or false. If nothing matches the condition, the application returns an error message unless you use the Every reference, in which case the application returns an empty list. Range: words 1 thru 4 of "We're all in this together" text from word 1 to word 4 of "We're all in this together"
|
||||||
Table of contents |