Specifications
Chapter 5. Data Types
75
5.5.4 Common Variables
A common variable should be declared in a main object beforehand. To share the common
variable by files other than the main object, you need to declare it with the
COMMON statement
in each file where the common variable should be available.
File 1
File 2
DECLARE SUB printaa(x) COMMON a%
COMMON a% SUB printaa(x)
a%=2 print a%+x
printaa(5) SUB
To use a% as a common variable in Files 1 and 2, define the variable with the COMMON state-
ment in each file.
If a common variable declared with the
COMMON statement is used within the SUB or FUNC-
TION
function in a file where the variable is defined, then the common variable will have the
same value.
(Example)
COMMON aa%
FUNCTION addaa(x)
addaa=aa%+x
END FUNCTION
SUB printaa(x)
print aa%+x
END SUB
aa%=2
print addaa(2)
printaa(2)
In the above example, variables aa% used in "addaa" and "printaa" will be treated as same
one.