Automatic and Static Variables
◄Variables► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Automatic and Static Variables
BASIC procedures can use automatic and static variables:
■ Automatic variables are initialized at the start of each call to the
FUNCTION or SUB.
■ Static variables retain values between calls.
Use STATIC keyword in the SUB or FUNCTION statement to control whether the
procedure's variables are automatic or static:
■ If you omit the STATIC keyword, then the variables are automatic.
■ When you use STATIC, then the variables in the procedure are static:
the values of the variables are saved between procedure calls.
You can make selected variables in a procedure static:
■ Make the default automatic by omitting STATIC from the SUB or FUNCTION
statement.
■ Then name one or more variables in a STATIC statement.