basic.dim Statement/BASIC Program

basic.dim

Command basic.dim Statement/BASIC Program
Applicable release versions: AP, R83
Category BASIC Program (486)
Description establishes a specific number of storage locations for a matrix of variables.

Arrays may be of one or two dimensions only. Individual elements within an array are accessed by appending the element number, enclosed in parentheses, to the array variable.

"rows" specifies the number of rows and "cols" specifies the number of columns of the array. These quantities may be any valid numeric expression.

A "dim" statement without the number of elements specified, such as in the case: "dim a()", may only be used in a subroutine. Pick/BASIC run-time determines the number of elements after a "matread".

An array must be dimensioned prior to being referenced within a program. After an array has been dimensioned, it may be redimensioned later within a program. When the dimensioning parameters are changed, the new array will:

- retain those elements with the same indexes that were in the old array;

- have any new elements initialized to a unassigned state;

- lose any unreferenced elements (those elements in the old array with indicies not present in the new array).

If an array is passed to a subroutine in an argument list, it cannot be redimensioned within the subroutine. A passed array can only be dimensioned once within a subroutine. Local arrays may be redimensioned as necessary. When arrays are dimensioned both in a subroutine and within the calling program, the dimensions specified in the calling program will supercede those specified within the subroutine, if the subroutine's array was dimensioned as an empty dimension. The number of dimensions must be the same in both the calling program and called subroutine.
Syntax dim{ension} array.variable({rows{,cols}})
Options
Example
dim rec(20),table(3,3)

"rec" is a single dimensional array with 20 subscripted variables. 
"table" is a two dimensional array with 9 subscripted variables.

x = 20
dim a(x)
input y
dim b(y)
dim c(x,y)

In AP, "dimension" can be handled by Pick/BASIC runtime.  On 
"R83" systems, "dim" can only be handled by the compiler 
and the argument must be a numeric constant.

subroutine process.receipt(receipt.item)
dim work.list()
...
matread work.list ...

This example illustrates a "dim" statement without arguments. It 
resolves the size of the array after the "matread".
Purpose
Related basic.array.references
basic.matread
basic.matwrite
basic.matbuild
basic.matparse
basic.call
basic.assignment
basic.dimension
basic.array.dimensioned
basic.statements
array
arrays.relational.expressions
basic.mat
basic.array.variable
basic.common
basic.(
basic.)