Language Guide

CHAPTER 6
Expressions
154 Variables
set myDoc to ref to document "Report" of application
"Scriptable Text Editor"
set myDoc to ref document "Report" of application
"Scriptable Text Editor"
After you create a reference with the A Reference To operator, you can use the
Contents property to get the value of the object that it refers to. The Contents
property is the value of the object specified by a reference. For example, the
result of the following expression is a string containing the text of document
Report of the Scriptable Text Editor.
contents of myDoc
Data Sharing 6
Data sharing allows you to create two or more variables that share the same
list, record, or script object data; it can be used to promote efficiency when
working with large data structures. Only data in lists, records, and script
objects can be shared; you cannot share other values. In addition, the shared
structures must all be on the same computer.
To create a variable that shares data with another variable whose value is a list,
record, or script object, use the Set command. For example, the second Set
command in the following example creates the variable yourList, which
shares data with the previously defined variable myList.
set myList to { 1, 2, 3 }
set yourList to myList --this command creates yourList,
--which shares data with myList
set item 1 of myList to 4
get yourList --result:{ 4, 2, 3}
If you update myList by setting the value of its first item to 4, then the value
of both myList and yourList is {4, 2, 3}. Rather than having multiple
copies of shared data, the same data belongs to multiple structures. When one
structure is updated, the other is automatically updated.