
72
If used inside the SUB or FUNCTION function in the same file where the global variable is
defined, the variable will also have the same value.
(Example 2) The variable aa% defined by the GLOBAL statement will have the same value as
aa% within the FUNCTION.
File 1
GLOBAL aa%
DECLARE SUB printaa(x)
FUNCTION addaa(x)
addaa=aa%+x
END FUNCTION
aa%=2
print addaa(2)
printaa(2)
File 2
GLOBAL aa%
SUB printaa(x)
print aa%+x
END SUB
If you link Files 1 and 2 above into a program file, the variable aa% used in those files will
have the same value.
If a same name variable
If a same name variableIf a same name variable
If a same name variable is used in one file where it is declared to be global
is used in one file where it is declared to be global is used in one file where it is declared to be global
is used in one file where it is declared to be global
and in the
and in the and in the
and in the
other file where it is not declared
other file where it is not declaredother file where it is not declared
other file where it is not declared
In those files where the variable is declared to be global by the GLOBAL statement, all of those
variables will have the same value. In a file where the variable is not declared, the variable is
available only in each file.
(Example) If in each of Files 1 and 2 the variable aa% is declared by the GLOBAL statement
and in File 3 the variable aa% is not declared:
File 1
GLOBAL aa%[50]
File 2
GLOBAL aa%[50]
File 3
PRIVATE aa%[50]
If you link Files 1, 2, and 3 above into a program file, the variables aa% in Files 1 and 2 will
have the same value and aa% in File 3 will be treated as a variable different from those in
Files 1 and 2.
Comentarios a estos manuales