MVDIM
Synopsis
MVDIM:pc array(rows,columns)
Arguments
Argument  Description 

pc  Optional — A postconditional expression. For further details, refer to Command Postconditional Expressions in Using Caché ObjectScript. 
array  Name of an array. Follows standard MVBasic variable naming conventions. 
rows  An integer specifying the number of array elements to dimension for a onedimensional array, or the number of rows to dimension for a twodimensional array. 
columns  Optional — For twodimensional (matrix) arrays, an integer specifying the number of columns per row. Can only be used in conjunction with the optional rows argument. 
Description
The MVDIM command explicitly dimensions a onedimensional or twodimensional MultiValue static array. Dimensioning of arrays is required for MultiValue applications.
Explicit dimensioning of arrays is not required (or supported) for ObjectScript. Arrays in ObjectScript are dynamic and multidimensional. For a description of arrays in ObjectScript, refer to “Multidimensional Arrays” in Using Caché ObjectScript.
Most MultiValue systems require you to explicitly dimension the rows and columns of a static array. These values specify the maximum number of elements that can be defined for that array. An explicitly dimensioned array is limited to two subscripts. It can be either onedimensional, representing a vector array, or twodimensional, representing the rows and columns of a matrix array. A onedimensional array can be dimensioned either as a vector array: MVDIM arrayname(n) or a matrix array with a column dimension of one: MVDIM arrayname(n,1).
The subscripts of a dimensioned array can be specified using named variables, as well as numeric indices. Variables whose names begin with a % are known as public arrays and their values are preserved across SUBROUTINE calls in a similar manner to COMMON arrays. Variables whose names begins with ^ are known as globals and their values are stored on disk automatically. Variables with normal naming conventions are known as local arrays and their value is lost when the program terminates, as with any other variable.
All uninitialized variables are treated as zerolength strings ("").
Caché MVBasic also allows you to dimension arrays of an arbitrary number of dimensions. This allows MVBasic to support the multidimensional arrays used in Caché. You specify a multidimensional array using a DIM statement with empty parentheses: DIM arrayname(). This declares array as a dimensioned array, but the number of dimensions and number of elements in each dimension may be expanded dynamically at runtime. Because ObjectScript normally creates arrays of this type, the MVDIM command does not provide an option for this type of implicit dimensioning.
Refer to the Caché MultiValue Basic Reference for further details.
Examples
The following examples illustrate the use of the MVDIM statement:
; Dimensions a onedimensional array with 10 elements.
MVDIM MyVector(10)
/* Dimensions a twodimensional matrix array
with 10 rows and 10 columns. */
MVDIM MyMatrix(10,5)
/* Dimensions a twodimensional array using local variables */
SET myrows=4,mycols=5
MVDIM MyMatrix(myrows,mycols)
See Also

SET command

DIM statement in Caché MultiValue Basic Reference

“Multidimensional Arrays” in Using Caché ObjectScript