DIM
Syntax: DIM {floatArray|integerArray|stringArray$}(integerDimension)
Normally variables are associated with a single value, however, there
are occasions when a variable needs to contain several values. The DIM
statement is used to initialise the number of items it contains. Each
item is accessed by appending the element number enclosed within
parenthesis to the variable name. Array elements are indexed from zero up
to the array dimension less one. Thus DIM I(3) defines 3 items: I(0), I(1)
and I(2). Access any of subscripts will cause a ARRAY_BOUNDS error to be
generated.
Take for instance a string variable called MONTH$. There are twelve months
in the year so we declare MONTH$ to be an array consisting of 12 values.
1000 DIM MONTH$(12)
1010 MONTH$(0)="January"
1020 MONTH$(1)="February"
...
1120 MONTH$(12)="December"
In many cases it is more convenient to initialise arrays using READ / DATA
statements.
Example
DIM I%(5)
DIM F(6)
DIM A$(7)
|