qb45advr.hlp (
Topic list)
BASIC Scoping Rules
◄Data Types► ◄Scoping Rules► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
Scoping Rules
The following list summarizes BASIC's scoping rules:
■ A variable declared in a DIM, REDIM, or COMMON statement with the
SHARED attribute is a global variable to a module. Any SUB or FUNCTION
procedure within the module can refer to the variable.
■ A symbolic constant is global if it is declared in a CONST statement in
the module-level code. Symbolic constants declared in a SUB or FUNCTION
are local.
■ A variable is a local variable if it appears in a procedure and is not
declared as a global variable. You can use the name of a global
variable as a local variable in a procedure by declaring it in the
procedure with the STATIC statement or by using it as a formal parameter.
■ The SHARED statement lets you share a variable with the module-level
code and other procedures with equivalent SHARED statements without
making the variable a global variable.
■ All variables in a DEF FN function are part of the module-level code
unless they are explicitly made local in a STATIC statement or are
formal parameters.
See Also ◄Scope of Variables and Constants►
◄Global Variables and Constants►
◄Local Variables and Constants►
◄Sharing Variables►
◄DEF FN Functions►