DekGenius.com
[ Team LiB ] Previous Section Next Section

11.5 Creating References to Local Variables

You can't make a reference to a local variable. Well, you can, but you won't be able to use it. For example:

local x
set x to {1, 2, 3}
set y to a reference to x
get item 1 of y -- error

This does not mean, however, that the only things you can create references to are top-level globals. You can make a reference to anything that isn't a local, such as a property:

script myScript
        property x : 5
        set y to a reference to x
        set contents of y to x + 1
        display dialog x
end script
run myScript -- 6
    [ Team LiB ] Previous Section Next Section