To make a name local to a user-defined function, it must be contained in the
function header. For example, the function header VZtEXAMPLE X;J;I estab-
lishes the result variable 2, the argument X, and variables J and I as local variables,
Notice that the local names, other than the result variable and arguments, follow
the right argument (if any) and are preceded by semicolons.
A local name can be the same as a global name (variable or user-defined function)
or a local name in another function. However, any reference to the name local
to the function will not change the values of any other global or local objects
(variables or user-defined functions) or cause them to be used.
After a user-defined function has executed, the following rules apply to the local
and global variables used by the function:
Any value assigned to a local variable is lost.
If a local variable had the same name as a global variable, the value of the glo-
bal variable remains unchanged.
If the value of a global variable was changed by the function, it retains the
new value.
For example:
I., (3 (:: f- :I. 0 0
(3 I., 0 B +* 1 0 0
V 14 I:: $1.1 I.., '1 t- E X AM F1 I.., E! ; I.., Cl (2 ; X
I:: 1. :I I., (2 I:: 4.. F.5 0
I" *.) 1 x +. q 1::-
I: 3 ::I GI.., I3 B 6. :I. 0
I:: 1.1. ::I I? I,: $3 1.1 I... 'r' (- I.., (1 c: .+ (3 I", I:) E .+* x v
E x A M 1:' I.., E
I3 5
V A I.., IJ I, EI: R I? C) R
Lo(: -
.. L. .. &.\.I
X has no value after the function
has executed.
The global value associated with this
name was unchanged by the function.
1 0 0
GLQB -The global value was changed by the
function, since GLOB was not made
local name to the function.
:I. 0
Previous Page Next Page