[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]

exceed 10 (11 items: 0 thru 10) then the array will be created by the Interpreter and filled with zeros (or nulls if string type) the first time any element of the array is referred to, otherwise the BASIC DIM statement must be used to define the shape and size of the array. The amount of memory required to store an array can be determined as follows:

5 bytes for the array name
+ 2 bytes for each dimension of the array
+ 2 bytes per element for integers
OR + 5 bytes per element for floating-point
OR + 3 bytes per element for strings
AND + 1 byte per character in each string element

Subscripts can be integer constants, variables, or an arithmetic expression which gives an integer result. Separate subscripts, with com- mas between them, are required for each dimension of an array. Subscripts can have values from zero up to the number of elements in the respective dimensions of the array. Values outside that range will cause the BASIC error message ?BAD SUBSCRIPT. Some examples of array names, value assignments and data types are:

A$(0)="GROSS SALES" (string array)
MTH$(K%)="JAN" (string array)
G2%(X)=5 (integer array)
CNT%(G2%(X))=CNT%(1)-2 (integer array)
FP(12*K%)=24.8 (floating-point array)
SUM(CNT%(1))=FP^K% (floating-point array)
A(5)=0 (sets the 5th element in the 1 dimensional array called "A" equal to 0)
B(5,6)=0 (sets the element in row position 5 and column position 6 in the 2 dimensional array called "B" equal to 0)
C(1,2,3)=0 (sets the element in row position 1, column position 2, and depth position 3 in the 3 dimensional array called "C" equal to 0)


Expressions are formed using constants, variables and/or arrays. An expression can be a single constant, simple variable, or an array variable

[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]
This page has been created by Sami Rautiainen.
Read the small print. Last updated November 13, 1998.