bas7advr.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.
STATIC Statement Details
◄Syntax► ◄Details► ◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
The STATIC statement makes simple variables or arrays local to a DEF FN
function, a FUNCTION procedure, or a SUB procedure, and preserves values
between calls.
STATIC variable[()] [AS type] [,variable[()] [AS type]]...
■ AS type declares the type of the variable. The type may be INTEGER,
LONG, SINGLE, DOUBLE, STRING (for variable-length strings),
STRING * length (for fixed-length strings), CURRENCY, or a user-
defined type.
Usage Notes
■ STATIC is a BASIC declaration that makes simple variables or
arrays local to a procedure (or a DEF FN function) and preserves
the variable values between procedure calls
■ The STATIC statement can appear only in a SUB procedure, FUNCTION
procedure, or DEF FN function.
■ Earlier versions of BASIC required the number of dimensions in
parentheses after an array name. The number of dimensions in BASIC
is now optional.
■ Variables declared in a STATIC statement override variables of the
same name shared by DIM or COMMON statements in the module-level
code. Variables in a STATIC statement also override global
constants of the same name.
■ Usually, variables used in DEF FN functions are global to the
module; however, you can use the STATIC statement inside a DEF FN
statement to declare a variable as local to only that function.
■ The differences between the STATIC statement, the STATIC attribute,
and the $STATIC metacommand are:
Statement/Attribute Differences
═══════════════════════ ════════════════════════════════════════
STATIC attribute on SUB Declares the default for variables to be
and FUNCTION statements static. Variables having the same name
as variables shared by the module-level
code are still shared.
STATIC statement Makes specific variables static and
overrides any variables shared by the
module-level code.
$STATIC metacommand Affects how memory is allocated for
arrays.