statement/DIM statement/DIM
NAME
DIM -- Presents and reserves memory for an array
ABBREVIATION
d <shift> I
SYNOPSIS
DIM <variable>(<subscripts>)[,<variable>(<subscripts>)][,<...>
[,<variable>(<subscripts>)]]
FUNCTION
Before you can use an array of variables, the program must first execute
a DIM statement to establish the DIMensions of that array (unless there
are 11 or fewer elements in the array). The statement DIM is followed by
the name of the array (<variable>), which may be any legal variable
name. Then, enclosed in parentheses, you put the number (or numeric
variable) of elements (<subscripts>) in each dimension. An array with
more than one dimension is called a matrix. You may use any number of
dimensions, but keep in mind that the whole list of variables you are
creating takes up space in memory, and it is easy to run out of memory
if you get carried away. To figure the number of variables created with
each DIM, multiply the total number of elements in each dimension of the
array.
You can dimension more than one array in a DIM statement by separating
the arrays by commas. If the program executes a DIM statement for any
array more than once, you'll get re'DIMed array error message. It is
good programming practice to place DIM statements near the beginning of
the program.
INPUTS
<variable> - array name (legal variable name)
<subscripts> - number of elements in an array
RESULT
Presents and reserves memory for an array or arrays.
EXAMPLES
DIM A$(40),B7(15),CC%(4,4,4)
! ! !
! ! +- 125 Elements
! +--------- 16 Elements
+---------------- 41 Elements
NOTES
Each array starts with element 0.
Integer (single-digit) arrays take up 2/5ths of the space of floating
point arrays.
BUGS
None
SEE ALSO
None