Language Guide

CHAPTER 6
Expressions
Variables 153
The “A Reference To” Operator 6
To create a variable whose value is a reference instead of the value of the object
specified by a reference, use the A Reference To operator. Here’s an example:
set myDoc to a reference to document "Report"
of application "Scriptable Text Editor"
The value of the variable myDoc is the reference
document "Report" of application "Scriptable Text Editor"
After you create a variable whose value is a reference, you can use it in a script
anywhere a reference is required. When AppleScript executes the statement
containing the variable, it replaces the variable with the reference. For example,
when AppleScript executes the statement
tell myDoc
get word 1
end tell
it replaces the variable myDoc with the reference document "Report" of
application "Scriptable Text Editor".
The syntax for using the A Reference To operator is
[a] ( ref [to] | reference to ) reference
where reference is a reference to an object. As indicated in the syntax description,
there are many ways to shorten expressions containing A Reference To. For
example, all of these expressions are equivalent:
set myDoc to a reference to document "Report" of
application"Scriptable Text Editor"
set myDoc to reference to document "Report" of
application "Scriptable Text Editor"
set myDoc to a ref to document "Report" of application
"Scriptable Text Editor"