The dimension statement establishes a specific number of storage locations for a matrix of variables.
|Can 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.
|Number of rows in the array. Can be any valid numeric expression.
|Number of columns in the array. Can be any valid numeric expression.
A dimension statement without the number of elements specified (such as in the case dim a()) can only be used in a subroutine. FlashBASIC or 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 can be re-dimensioned later within a program. When the dimensioning parameters are changed, the new array:
If an array is passed to a subroutine in an argument list, it cannot be re-dimensioned within the subroutine. A passed array can only be dimensioned once within a subroutine. Local arrays can be re-dimensioned as necessary. When arrays are dimensioned both in a subroutine and within the calling program, the dimensions specified in the calling program supersede 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.
The dim statement can be handled by FlashBASIC or BASIC runtime.
x = 20 dim a(x) input y dim b(y) dim c(x,y)
This example illustrates a dim statement without arguments. It resolves the size of the array after the matread.
subroutine process.receipt(work.list) dim work.list() ... matread work.list...