Previous Up Next

4.6.7  Copying variables

If a variable has a value, such as

a := 1

and you set a second variable to the first variable

b := a

the new variable will have the same value as the first; in this case b will be equal to 1. If you later give the first variable a new value;

a := 5

the new value will still have the old value, in this case, b will still be equal to 1.

The CopyVar command will copy one variable to another without evaluating the first variable; the new variable will simply be a copy of the first. With a having the value of 5, as above, the command

CopyVar(a,c)

will make c a copy of the variable a, so it will have the value 5 also. If you now change the value of a

a := 10

then the value of c will also change; here, c will now have the value 10.


Previous Up Next