January 2006
Beginner
592 pages
16h 55m
English
You can't make a reference to a local variable. Well, you can, but if you try to use it you'll get a mysterious error. For example:
local x
set x to {1, 2, 3}
set y to a reference to x
get item 1 of y -- error: Can't make item 1 of x into type referenceBut a reference can itself be stored in a local variable:
local y
set x to {1, 2, 3}
set y to a reference to x
get item 1 of y -- 1You can make a reference to anything that isn't a local, such as a global or a top-level entity:
script myScript
property x : 5
set y to a reference to x
set contents of y to y + 1
display dialog x
end script
run myScript -- 6That works just as well from outside of the script object:
script myScript
property x : 5
display dialog x
end script
tell myScript
set y to a reference to its x
set contents of y to y + 1
run -- 6
end tellRead now
Unlock full access