DIM


The DIM statement is used to declare arrays to the compiler before they are referenced.

 

COMMAND SYNTAX

DIM{ENSION} variable(number{, number... }){, variable(number {,number...}) ...}

 

SYNTAX ELEMENTS

The variable may be any valid variable name that has not already been used or declared. The numbers define the size of each dimension and must be either constants or the subject of an EQUATE statement.

A number of arrays may be declared by a single DIM statement by separating their declarations with a comma.

 

NOTES

The array must be declared before it is referenced in the program source (compilation as opposed to execution). The compiler will display an error message if a variable is used as a dimensioned array before it has been declared.

The array variable may not be used as a normal variable or dynamic array before being dimensioned and the compiler will detect this as an error.

A dimension size may not be specified as 1 as this has no logical meaning. The compiler will detect this as a warning.

When arrays are referenced directly as in A = Array(7), the compiler will optimize the reference as if it was a single undimensioned variable.

If the emulation option resize_array=true is set, then the array may be dimensioned with a variable. It can also be resized (i.e. redimensioned).

See also: COMMON

 

EXAMPLES

EQUATE DimSize1 TO 29
DIM Array1(10,10), Array2(5, 20, 5, 8)
DIM Age(DimSize1)


jBC