Specifications
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
File 2
GLOBAL aa% GLOBAL aa%
DECLARE SUB printaa(x) SUB printaa(x)
FUNCTION addaa(x) print aa%+x
addaa=aa%+x END SUB
END FUNCTION
aa%=2
print addaa(2)
printaa(2)
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 is used in one file where it is declared to be global
and in the 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
File 2 File 3
GLOBAL aa%[50] GLOBAL aa%[50] dim 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.