Skip to main content


Dimensions an array of variables for MultiValue use.


MVDIM:pc array(rows,columns)


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 one-dimensional array, or the number of rows to dimension for a two-dimensional array.
columns Optional — For two-dimensional (matrix) arrays, an integer specifying the number of columns per row. Can only be used in conjunction with the optional rows argument.


The MVDIM command explicitly dimensions a one-dimensional or two-dimensional 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 one-dimensional, representing a vector array, or two-dimensional, representing the rows and columns of a matrix array. A one-dimensional 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 zero-length 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.


The following examples illustrate the use of the MVDIM statement:

 ; Dimensions a one-dimensional array with 10 elements.
 MVDIM MyVector(10)
 /* Dimensions a two-dimensional matrix array 
    with 10 rows and 10 columns. */
 MVDIM MyMatrix(10,5)
 /* Dimensions a two-dimensional array using local variables */
 SET myrows=4,mycols=5
 MVDIM MyMatrix(myrows,mycols)

See Also

FeedbackOpens in a new tab