Commodore 128 System Manual page 264

Hide thumbs Also See for 128:
Table of Contents

Advertisement

DIM
Declare number of elements in an array
DIM variable (subscripts) [,variable(subscripts)][...]
Before arrays of variables can be used, the program must first
execute a DIM statement to establish DIMensions of the array
(unless there are 11 or fewer elements in each DIMension of the
array). The DIM statement is followed by the name of the array,
which may be any legal variable name. Then, enclosed in
parentheses, the number (or numeric variable) of elements in
each dimension. An array with more than one dimension is called
a matrix. Any number of dimensions may be used, but keep in
mind the whole list of variables being created takes up space in
memory, and it is easy to run out of memory if too many are used.
Here's how to calculate the amount of memory used by an array:
5 bytes for the array name
2 bytes for each dimension
2 bytes/elements for integer variables
5 bytes/elements for normal numeric variables
3 bytes/elements for string variables
1 byte for each character in each string element
Integer arrays take up two-fifths the space of floating-point arrays
(e.g., DIM A% (100) requires 209 bytes; DIM A (100) requires 512
bytes.)
NOTE: Elements are numbered from 0 eg DIM A(100) gives 101
elements.
More than one array can be dimensioned in a DIM statement by
separating the array variable name by commas. If the program
executes a DIM statement for any array more than once, the
message " RE'DIM ARRAY ERROR" is posted. It is good
programming practice to place DIM statements near the
beginning of the program.
EXAMPLE:
10 DIM A$(40),B7(15),CC%(4,4,4)
41 elements, 16 elements, 125 elements
17-22

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

128d

Table of Contents