bas7qck.hlp (Table of Contents; Topic list)
Global Variables and Constants
  Scope Rules  Variables                     Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
Global Variables and Constants
 
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.
 
See Also    Sharing Variables