int e l 4.7 DESCRIPTION OF STATEMENTS STATEMENT: DIM MODE: COMMAND AND/OR RUN TYPE: ASSIGNMENT DIM reserves storage for matrices. The storage area is first assumed to be zero. Matrices in MCS BASIC- 52 may have only ONE DIMENSION and the size of the dimensioned array MAY NOT exceed 254 elements. Once a variable is dimensioned in a program it may not be re-dimensioned. An attempt to re-dimension an array will cause an ARRAY SIZE ERROR. If an arrayed variable is used that has NOT been dimensioned by the DIM STATEMENT, BASIC will assign a default value of 10 to the array size. All arrays are set equal to zero when the RUN COMMAND, NEW COMMAND, or the CLEAR STATEMENT is executed.
The number of bytes allocated for an array is 6 times the (array size plus 1). So, the array A(100) would require 606 bytes of storage. Memory size usually limits the size of a dimensioned array. VARIATIONS: More than one variable can be dimensioned by a single DIM STATEMENT, i.e., DIM A(10), B(15), A1(20). EXAMPLE: DEFAULT ERROR ON ATTEMPT TO RE-DIMENSION ARRAY >10 A(5)=10 - BASIC ASSIGNS DEFAULT OF 10 TO ARRAY SIZE HERE >20 DIM A(5) - ARRAY CANNOT BE RE-DIMENSIONED >RUN ERROR ARRAY SIZE - IN LINE 20 20 DIM A(5) -------x - 35 -