Liberty BASIC Help Online

Liberty BASIC supports single and double dimensioned arrays.  These can be defined as string or numeric arrays.  The extents of the dimensions can be in excess of 2 million elements, if there is enough RAM available. 
Arrays that contain more than 10 elements must be dimensioned before they can be used.  Arrays are dimensioned with the DIM statement.
DIM students$(20)
DIM ages(100)
Resizing is done to any array with the REDIM statement, but doing so will erase the contents of the array.
REDIM students$(30)
Double dimensioned arrays must always be dimensioned with the DIM statement before use.
DIM scores$(20, 10)
The equal sign ( = ) is used to assign a value to an element in an array.  The element is referred to by its index number.  The index may be expressed as a literal number or as a numeric variable.  The element at index 2 in the following example is filled with "John."  The element at index 7 is filled with the number 12.
students$(2) = "John"
ages(7) = 12
Arrays can be used in most places where a variable or literal value can be used. To access the value of an element in an array, the index for that element is placed inside the parentheses.  In this example, the value at index 4 is retrieved from the array:
thisKid$ = students$(4)
print students$(4)
Using Arrays in Loops
One of the great advantages of arrays is their ability to be accessed in loops, as in the following example, which prints the names of elements 1 - 30 that are contained in the array.
for i = 1 to 30
    print students$(i)
Input to Arrays
In earlier versions of Liberty BASIC, it wasn't possible to input directly into arrays.  That limitation no longer exists in Liberty BASIC 3.  It is now possible to use both Input and Line Input to read data from opened files directly into arrays.
'now works:
open "myfile.dat" for input as #f
input #f, itemArray$(1)
close #f
It is still necessary to READ data into a variable, then fill an array element, however:
read numericArray(1)
read num1
numericArray(1) = num1
For more, see ARRAYS, DIM, SORT, and Sorting Arrays.

Copyright (C) 2003 Shoptalk Systems
Liberty BASIC -