qb45advr.hlp (
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Global Variables and Constants
◄Scoping Rules► ◄Global Variables and Constants► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
Global Variables and Constants
Both variables and symbolic constants can be global in BASIC programs. A
global variable or global symbolic constant is defined for the entire
module.
■ A symbolic constant is a global constant if it is declared in the
module-level code using a CONST statement.
■ For a variable, the only way to make it global is to declare it in the
module-level code with the SHARED attribute in a DIM, REDIM, or COMMON
statement. For example, the following program fragment makes TabStops a
global variable.
DIM SHARED TabStops(MAXLINE)
.
.
.
SUB SetTabPos STATIC
.
.
.
END SUB
FUNCTION ThisIsATab(LastColumn AS INTEGER) STATIC
.
.
.
The SHARED statement (as opposed to the SHARED attribute, used above) allows
particular procedures to share variables with the module-level code. This is
not the same as making the variable global. It is only global for the
module-level code and all procedures with SHARED statements for the variable.