39
EXAMPLE
:
Declare array variable A for storage of 9 numeric data items.
10 DIM A (8)
Note: a declared value of 8 makes possible to store 9 data items.
EXAMPLE:
Recall value stored in element 4 of array A
Y=A(4)
Or
X=4:Y=A(X)
The value that specifies an element in an array (4 above) is called a subscript.
Until now, the only arrays covered have been those formed by a single line of
elements or “boxes”. These are known as “one-dimensional” arrays. Arrays may also
contain more than one dimension with elements connected vertically and horizontally
into two-dimensional and three-dimensional arrays.
EXAMPLE
:
DIM A (2,3)
The declaration in this example sets up an array of three lines and four columns,
making it capable of storing 12 different values.
As with simple variables, arrays can also be declared to hold strings by using the “$”
symbol following the array variable name.
A(0)
A(1)
A(2)
A(3)
A(4)
A(5)
A(6)
A(7)
A(8)
A(0,0)
A(0,1)
A(0,2)
A(0,3)
A(1,0)
A(1,1)
A(1,2)
A(1,3)
A(2,0)
A(2,1)
A(2,2)
A(2,3)