INMAT()

INMAT()

Top  Previous  Next

 

The INMAT() function provides qualifying information after certain statements are executed.

 

 

Format

 

INMAT({mat})

 

where

 

matis the name of a matrix.

 

 

Used without a mat matrix name, the INMAT() function returns information relating to the last use of the following statements

 

DIMENSION0 if successful, 1 if insufficient memory.
JPARSE()The character position at which parsing of a JSON string detected an error.
MATBUILDThe index of the final non-null element, zero if the zero element was not null.
MATCHFIELD()The value within a multivalued pattern that matches the string.
MATPARSEThe number of elements assigned. Zero if overflows.
MATREADThe number of elements assigned. Zero if overflows.
MATREADLThe number of elements assigned. Zero if overflows.
MATREADUThe number of elements assigned. Zero if overflows.
MATWRITEThe index of the final non-null element, zero if the zero element was not null.
OPENThe modulus of a dynamic file.
PAUSEThe user number of the process performing the WAKE.
Pattern matchingThe value position within a multivalued pattern that matches the string.

 

 

Further details of the information returned by INMAT() in each case is documented with the relevant statement.

 

Used with a matrix name, the INMAT() function returns the current dimensions of the matrix, including matrices in data collection variables. If mat is a single dimensional matrix, INMAT() returns the number of elements, excluding the zero element. If mat is a two dimensional matrix, INMAT() returns the number of rows and columns as two values separated by a value mark.

 

 

Examples

 

DIM A(N)

IF INMAT() THEN ABORT "Insufficient memory"

 

This program fragment dimensions matrix A and tests whether it was successful. If not, the program aborts. With memory sizes found on modern computer systems, dimensioning a matrix is very unlikely to fail and this test is usually omitted.

 

 

N = INMAT(A)

FOR I = 1 TO N

  A(I) += 1

NEXT I

 

This program fragment adds one to each element of matrix A. The INMAT() function is used because the matrix was dimensioned elsewhere and hence its size is not known.