DIMENSION Statement

Dimensions arrays so they can be used in a DataBasic program.

Syntax

DIM{ENSION} arrayName(dimensions){,arrayName(dimensions)...}

Syntax Elements

arrayName The name of the array to be dimensioned.

dimensions The size of the array.

An array can be one-dimensional, (vector) or two-dimensional (matrix). See Dimensioned Arrays for more details and the limits on the number of elements.

Comments

The maximum dimensions of an array must be specified with a DIMENSION or COMMON statement. The dimensions must be declared with literal integers greater than 0 or symbols that represent literal integers, separated by commas. A DIMENSION (or COMMON) statement must precede any reference to the array it dimensions and is usually placed at the beginning of the program.

An array that is specified in a COMMON statement must not be specified in a DIMENSION statement.

You can dimension several arrays with a single DIMENSION statement. For example:

DIMENSION A1(10, 5), X(50)

This example declares Array A1 as a 10 by 5 matrix and declares Array X as a 50-element vector.

Notes:

  • An array can be dimensioned only once throughout the entire program.
  • Do not use any DataBasic reserved word as an array name.

Examples

DIMENSION MATRIX(10, 12)

Specifies a 10 by 12 matrix called MATRIX.

EQU ROWS TO 10
EQU COLS TO 12
.
.
.
DIMENSION MATRIX(ROWS, COLS)

Specifies the same matrix as above, using symbols for the dimensions.

DIM Q(10), R(10), S(10)

Specifies 3 vectors named Q, R and S, each of which contains 10 elements.