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.
Local Variables and Constants
  Scoping Rules   Local Variables and Constants   Contents   Index
──────────────────────────────────────────────────────────────────────────────
Local Variables and Constants
 
A local variable or constant exists only within a procedure or the module-
level code. If the name of a local variable is used in another procedure in
a module, the name represents a different variable and refers to a
different object.
 
It is simplest to think of a local variable as any variable that isn't
global. Any variable that appears in module-level code or in a procedure is
local if it isn't declared in a DIM, REDIM, or COMMON statement with the
SHARED attribute. Even if a variable appears in one of these statements,
you may still use a local variable of the same name in a procedure by
declaring the variable in a STATIC statement.
 
Any symbolic constant declared inside a SUB or FUNCTION procedure is a local
constant. For example, in the following fragment, ENDOFLIST is a local
symbolic constant that exists only in the function FindElement:
 
  FUNCTION FindElement(X())
  CONST ENDOFLIST = -32767
  .
  .
  .
  END FUNCTION
 
Note: The STATIC statement not only declares a variable to be local, it also
      directs the compiler to save the value of the variable between
      procedure calls. Do not use STATIC statements in recursive procedures
      if you do not want a variable's value saved between calls.