Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRIS, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions page (login required).

Previous sectionNext section


Returns the number of array elements.




array Optional — The name of a dimensioned array; must be a literal name, not enclosed with quotes. If omitted, the most recently parsed dimensioned array.


The INMAT function has two uses:

  • INMAT(array) returns the defined dimensions of the named array.

  • INMAT() returns the number of elements loaded into the most recently parsed array.

Before invoking INMAT, an array must have been dimensioned using the DIM (or DIMENSION) statement.

INMAT(array) takes the name of a dimensioned array and returns a two-element dynamic array containing the rows and columns dimensions of the array. If the DIM did not specify a columns dimension, INMAT returns 1 as the columns dimension.

Specifying an array value that is not a dimensioned array results in a #1039 compile error. The array must be an explicitly dimensioned static array. Specifying an implicitly dimensioned (dynamic) array results in a runtime <ARRAY DIMENSION> error.

INMAT() defaults to the most recently loaded array. It returns an integer specifying the number of elements that were loaded using a MATREAD, MATREADU, or MATPARSE statement. If no array has been loaded, or the most recently loaded array was loaded with the null string or with a single element, INMAT() returns 1.


The following example returns the row and column dimensions of a dimensioned array:

DIM MyArray(6,5)
    ! Returns 6ý5
Copy code to clipboard

The following example returns the number of dimensioned array elements parsed by MATPARSE:

DIM MyArray(6,5)
    ! Returns 3
Copy code to clipboard

See Also