Language Guide

CHAPTER 9
Script Objects
284 Using the Copy and Set Commands With Script Objects
Now consider the following example, which uses the Copy command to define
the variable myScriptObject.
script John
property Vegetable: "Spinach"
end script
copy John to myScriptObject
set Vegetable of John to "Swiss chard"
get Vegetable of myScriptObject
--result: "Spinach"
In this case, the Copy command creates a new script object. Setting the
Vegetable property of the original script object has no effect on the new script
object. The result of the Get command is "Spinach".
When you copy a child script object to a variable, the variable contains a
complete copy of both the child and its parent, including all the parent’s
properties and handlers. Each new copy, including its inherited properties
and handlers, is completely independent of both the original and any
other copies.
For example, if you copy a modified version of the JohnSon script in this
example to two different variables, you can set each variable’s Vegetable
property independently:
script John
property Vegetable : "Spinach"
end script
script JohnSon
property parent : John
on changeVegetable(x)
set my Vegetable to x
end changeVegetable
end script