Format: DIM var list
Supported by: COMX BASIC V1.00, Floating Point BASIC 2.2, Pecom 32 BASIC, Pecom 64 BASIC 1.0 and 4.0, Quest Super BASIC 1.4, 3.0, 5.0 and 6.0, RCA BASIC3 V1.1, Telmac SBASIC v 24.3
Similar commands: -
This statement (dimension arrays) serves to reserve memory for arrays of numbers. These arrays may be one dimensional or two dimensional. The expression defines how large the array is in one or both dimensions. The mode of the array (floating point or integer) depends on whether its associated variable name has been defined as either integer or floating point. For instance, if all variables A-Z are floating point, then all arrays will be floating point (independent of the mode of the expression defining its limits). If variables A, B, and C are defined as integer, then arrays named A, B and C (if used) will be defined as integer. Multiple arrays may be dimensioned in the same DIM statement so long as each array is separated by a comma.
If memory is exceeded when an array is being dimensioned, an error message will result. Trying to use any array element that has not been previously dimensioned will also result in an error message. The programmer can use a CLD statement to clear all unwanted data space in order to reclaim all data space.
The following is an example of a DIM statement.
DIM A(10, 10), B(20)
The above example sets aside space for 100 numbers (10 x 10) with the names ranging from A(1, 1) to A(10, 10) and 20 numbers with names ranging from B(1) to B(20).
The dimension statement can be used in the direct mode of execution if desired. Any arrays generated by a program remain intact after program execution is completed. One can interrogate the contents of any array in the direct mode by means of the PRINT statement. The array remains intact until a CLD is executed or any editing to the program is done. Note that if a "RUN expr" is executed, the data space is not cleared and the array has not been deleted. In this case, re-dimensioning will result in an error message. For that reason, the programmer should begin execution at a line-number after the DIM statement, if he wants to use previously generated data. The array data as well as the string data, exists directly after the user space. Any editing of the original program will alter the user space and thus destroy the data. It should be noted that an array can be re-dimensioned without destroying other arrays or strings.