Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 2 - AppleScript Language Reference
Chapter 5 - Objects and References / References


Complete and Partial References

A complete reference has enough information to identify an object or objects uniquely. For a reference to an application object to be complete, its outermost container must be the application itself, as in

paragraph 10 of document "Report" of application ÿ
   "Scriptable Text Editor"
In contrast, partial references do not specify enough information to identify an object or objects uniquely; for example:

word 1 of paragraph 10
When AppleScript encounters a partial reference, it attempts to use the default target specified in the Tell statement to complete the reference. The default target of a Tell statement is the object that receives commands if no other object is specified. For example, the following Tell statement tells the Scriptable Text Editor to delete the first paragraph of the front document.

tell paragraph 1 of front document of application ÿ
   "Scriptable Text Editor"
      delete
end tell
Similarly, the following Tell statement tells the Scriptable Text Editor to delete the third word of the first paragraph of the front document.

tell paragraph 1 of front document of application ÿ
   "Scriptable Text Editor"
      delete word 3
end tell
Tell statements can contain other Tell statements, called nested Tell statements. When AppleScript encounters a partial reference in a nested Tell statement, it tries to complete the reference starting with the innermost Tell statement. If that does not provide enough information, AppleScript uses the direct object of the next Tell statement, and so on. For example, the following Tell statement is equivalent to the previous example.

tell front document of application "Scriptable Text Editor"
   tell paragraph 1
      tell word 3
         delete
      end tell
   end tell
end tell

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996