guides:programming:programmers_reference_manual:dimension

Dimension statement

Declares the name of a matrix, and allocates storage for it. A matrix must be dimensioned before it can be referenced in a program.

You can use Dim for Dimension.

Dimension matrix(row [,column]) [, matrix(row [,column]) …]

- OR -

Dim matrix(row [,column]) [, matrix(row [,column]) …]

The Dimension statement has the following parameters.

ParameterDescription
matrixAny legal identifier. If more than one matrix is declared, the full declarations (name, row, and optional column) are delimited by commas.
rowAn integer identifying the number of rows in matrix. Numbers resulting from expressions will be truncated to their integer value.
columnAn integer identifying the number of columns in matrix. Numbers resulting from expressions will be truncated to their integer value. The row and column arguments must be separated by a comma.

The maximum number of elements in a matrix cannot be increased during the execution of a program. A one-dimensional matrix cannot be reassigned to be a two-dimensional matrix.

Note:

The Dimension statement only names the matrix and defines its dimensions; it does not assign values to the elements.

Zero-ith element: BASIC+ automatically allocates space for a 0 (zero) element when a matrix is dimensioned. That is, one more element is always available to receive data than is dimensioned in the Dimension statement. It is a single element, not a row or column. The data in the 0 (zero) element can be accessed by using a 0 (zero) subscript:

Matrix(0)

/* Two matrices are dimensioned. MONTH has 13 elements including a 0 (zero) element. YEAR has 61 elements (12 rows by 5 columns, plus a 0 (zero) element). */
Dim MONTH(12), YEAR(12, 5)

/* The number of rows in matrix TESTB is the current value of X and the number of columns is the current value of Y. */
Dim TESTB(X, Y)

/* Matrices named V, K, and R; each to contain 11 elements. The additional element in each is the 0 (zero) element. */
Dim V(10), K(10), R(10)
  • guides/programming/programmers_reference_manual/dimension.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1