English
Language : 

NSB8 Datasheet, PDF (88/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
grifo®
ITALIAN TECHNOLOGY
50 PRINT \ REM Print <CR> before starting next row
60 NEXT
Space for arrays is reserved by the programmer using the DIM statement. A DIM statement specifies
how many dimensions an array will have, and what the maximum index will be in each dimension.
10 DIM X (1000), Y (2,3), Z (10,10,10)
The above defines an array X consisting of elements indexed from 0 to 1000 (1001 elements
altogether), a two dimensional array Y with maximum row index of 2 and maximum column index
of 3, and a three dimensional array Z with dimensions of 10, 10, and 10. In keeping with the zero
element convenience feature mentioned above, each array dimension includes a zero element, so that
array Z above actually contains 11 elements, instead of 10, in each dimension, indexed from 0 to 10.
When more than one dimension is specified, the maximum indices must be separated by
commas. Commas must also separate array declarations when more than one occurs in a single DIM
statement.
The maximum index for any dimension in an array declaration may also be given in the form of a
numeric expression. If the variable Q contains the value 10, then the following DIM statement will
result in the creation of the same arrays as the previously given one:
10 DIM X (Q*Q*Q), Y (Q/5,3), Z (Q,10,SQRT (Q*Q) )
An array may have any number of dimensions, but arrays with many dimensions tend to take up huge
amounts of memory space. Consider that an array F, declared as F (10,10,10,10), will result in the
reservation of 14,641 variable spaces in memory! This corresponds to 11*11*11*11, not 10*10*10*10,
remember the 0 element in each dimension!. Each element of the array takes up several bytes, and
chances are this particular array would be too large to fit in the memory of your computer.
Whenever there is not enough memory available in the program/data area to hold an array, a
MEMORY FULL ERROR occurs.
DEFAULT DIMENSIONS
All arrays of more than one dimension and most one dimension arrays must be declared in DIM
statements before being used. However, it is not necessary to declare a one dimensional array of
maximum index 10 or less. Any array which is used without first being declared in a DIM statement
is automatically created by BASIC to be one dimensional, and of maximum index 10. If you desire
a specific maximum index greater or smaller than 10, however, you must use a DIM statement to
create the array. An attempt to reference an element in a multi dimensional array before the array has
been dimensioned in a DIM statement will fail, causing an OUT OF BOUNDS ERROR. When
dimensioned, an array is automatically initialized so that all of its elements contain the value 0.
ARRAYS MAY NOT BE REDIMENSIONED
No matter how created, either by an explicit declaration in a DIM statement or automatically, by
BASIC, no array may be redimensioned in another DIM statement later during program
execution. Specifically, this means that the size of arrays may not grow or shrink during the RUN
of a program. Any attempt to redimension an existing array will result in a DIMENSION ERROR.
Page 76
NSB8
Rel. 5.10