|Liberty BASIC Help Online
DIM array( )
DIM array(size) -or- DIM array(size, size)
DIM array1(size1), array2(size2), array3(size3), etc.
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.
print "Please enter 10 names."
for index = 0 to 10
input names$ : name$(index) = name$
'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.
print "Please enter 20 names."
for index = 1 to 20
input names$ : names$(index) = name$
Double subscripted arrays can store information more flexibly:
dim customerInfo$(10, 5)
print "Please enter information for 10 customers."
for index = 0 to 9
input "Customer name >"; info$ : customerInfo$(index, 0) = info$
input "Address >"; info$ : customerInfo$(index, 1) = info$
input "City >"; info$ : customerInfo$(index, 2) = info$
input "State >"; info$ : customerInfo$(index, 3) = info$
input "Zip >"; info$ : customerInfo$(index, 4) = info$
Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/