BASIC PROORAMMING SECTION 4.9
Individual array elements are identified by the array name and
the element number, together with a character to identify the
array type. For instance:
NOTE: Arrays start from element 0
A(10) is the eleventh element of simple variable array A.
A!(2) is the third element of double precision array A! (quite
different and independent from array A in the example above).
A$(0)is the first element in string array A$. .s$(0) is
identical with A$, which can be used for shorthand, useful if
there are multiple references to a single string in the program.
In each case, the number in parentheses is the
element number,
and can be variable: A$(A)
or an expression:
A$(A*5)
or another array element: A$((6))
Remember the element numbers start from O!
4,9,2,3
Creating Arrays
i/EP.V09F
Arrays can only be created once: if a subsequent attempt is made
to re-define an existing array, an error occurs. This is to
warn the programmer that he may be accidentally duplicating an
array name.
If the statement DIM A$(1,6) is repeated at a111ytime an error
message:
*DIM Error
will appear.
This can be easily avoided by incorporating the DIM in a program
sequence that is only executed once, and subsequently branched
around. This is often called an
Initialisation Sequence. A
typical format is:
10 IF Z<>O THEN 100
20 DIM A$(1,6)
30 2=55
PAGE 4 - 26