STATIC

Reserves storage for STATIC variables and arrays.
 
 STATIC item [,item...]
 
Where:
item = numeric-name[(bounds)] [=initial numeric value] [BUFFER] | string-name$[(bounds)]’[’length’]’ [=initial string value] [BUFFER]
  bounds = [lower-bound:]upper-bound [,bounds...]
 
Usage:
STATIC INTEGER Myint
STATIC REAL Myreal=5.7
STATIC INTEGER Intarray(100)
STATIC LONG Longarray(100)=10
STATIC A1$[100] BUFFER
STATIC A2$[100]="This is a test"
STATIC A3$(100)[100]
STATIC A4$(100)[100]="This is a test" BUFFER
STATIC INTEGER J1,J2=1,J3(100,200,400,500,600),LONG J4(100)=0 BUFFER
Description:
STATIC is a data condition. STATIC variables are persistent during a single run of an HTBasic program. Typically, STATIC variables will only be used in SUB programs and/or FN functions because the MAIN context is usually called only once.
 
STATIC variables can effectively take the place of COM variables as they are presently used in many cases. If access to a COM variable is required in multiple SUBs and/or Functions (DEF FN) and/or the Main context, then a STATIC variable is not appropriate. The scope of a STATIC variable is limited to the context in which it is declared. In other words, a STATIC variable declared in a SUB program cannot be accessed anywhere other than within that particular SUB program, however, it will retain the variable value between calls to that subroutine.
 
Up to 6 bounds may be specified, the initial values are optional. Specifying an initial value for an array initializes each individual element in all dimensions of the array to the initial value specified.
See Also: