HTBasic Help
×
Menu
Index

ALLOCATE

Dynamically allocates memory for string variables and arrays.
 
 ALLOCATE item [,item...]
 
Where:
item = [type] numeric-array (bounds) | variable-name$ [ (bounds) ] '['length']'
type = REAL | INTEGER | COMPLEX
bounds = [lower-bound:] upper-bound [,bounds...]
 
Usage:
ALLOCATE Chart(Down:Up)
ALLOCATE M$[LEN(N$)+1]
ALLOCATE Group$(Section)[50]
ALLOCATE INTEGER Myarray(Type,3,5)
 
Example:
 
Description:
The lower and upper bound range is -32,768 through +32,767, with the default lower bound range being the OPTION BASE (0 or 1). The string length is a numeric expression rounded to an integer in the range of 1 through 32,767.
 
ALLOCATE variables cannot appear in COM, COMPLEX, DIM, INTEGER or REAL declaration statements or be declared in the subprogram parameter list.
DEALLOCATE frees allocated memory, but because of stack requirements the freed memory does not become available unless all allocated items are also deallocated. In addition, ON event statements also use the stack and will not allow the deallocated memory to be available for use until the ON event statements are released from the stack. Memory ALLOCATEd within a subprogram is DEALLOCATEd upon exit of that subprogram.
 
After a variable has been deallocated, it can be reallocated with a different size as long as it has the same type and number of dimensions.
 
See Also: