DIM sets the maximum size of an array. Any array can be dimensioned to have as many elements as memory allows. If an array is not DIMensioned explicitly, then the array will be limited to 11 elements, 0 to 10. Non DIMensioned double subscript arrays will be limited to 100 elements 0 to 9 by 0 to 9. The DIM statement can be followed by a list of arrays to be dimensioned, separated by commas.

Usage:

'Example 1

print "Please enter 10 names."

for index = 0 to 10

input names$ : name$(index) = name$

next index

'Example 2

'Dimension three arrays at once

dim arrayOne(100), arrayTwo$(100, 5), arrayThree(100, 100)

The FOR . . . NEXT loop in the example above is limited to a maximum value of 10 because the array names$( ) is not dimensioned, and therefore is limited to 11 elements, numbered 0 - 10. To remedy this problem, add a DIM statement, as in the example below. Notice that it is not necessary to use all available index numbers. In the example the array is filled beginning at index 1, ignoring index 0.