The MATPARSE statement is used to assign the elements of a matrix from the elements of a dynamic array.



MATPARSE array{, expression1{, expression2}} FROM variable1 {USING expression3} SETTING variable2



array is a previously dimensioned matrix, which will be assigned to from each element of the dynamic array. variable1 is the jBC variable from which the matrix array will be stored. expression1 and expression2 should evaluate to numeric integers. expression1 specifies which element of the array the assignment will start with; expression2 specifies which element of the array the assignment will end with (inclusive).

By default, each array element in the dynamic array is assumed to be separated by a field mark. By specifying expression3, the separator character can be changed. If expression3 evaluates to more than a single character, only the first character of the string is used.

As assignment will stop when the contents of the dynamic array have been exhausted, it can be useful to determine the number of matrix elements that were actually assigned to. If the SETTING clause is specified then variable2 will be set to the number of elements of the array that were assigned to.



When specifying start and end positions with multi-dimensional arrays, it is necessary to expand the matrix into its total number of variables to calculate the correct element number. See the information about dimensioned arrays earlier in this section for detailed instructions on calculating element numbers.

It is our opinion that MATBUILD and MATPARSE have been named the wrong way round, but imagine the confusion if we had changed them!



DIM A(40)

Assign 5 elements of the array starting at element 3.