Caché MultiValue Basic Reference
MATPARSE
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Builds a dimensioned array from a dynamic array.
Synopsis
MATPARSE array [,start [,end]] FROM dynarray [USING delimiter]
Arguments
array Name of an existing dimensioned array. This array must have been dimensioned using the DIM statement.
start Optional — An integer that specifies the first dimensioned array element to receive a value. The default is 1.
end Optional — An integer that specifies the last dimensioned array element to receive a value. You must specify a start value to specify an end value. The default is the last element in array.
dynarray An existing dynamic array, each element of which is transcribed to the corresponding dimensioned array element.
USING delimiter Optional — Specifies the dynamic array delimiter character used to define separate elements. The default is a field mark (@FM).
Description
The MATPARSE statement assigns the values of the elements of a dynamic array to a dimensioned array. You can create a dimensioned array containing all of the element values of the dynamic array, or you can limit the transcription of dynamic array elements to those only dimensioned array elements between start and end.
Note:
This statement cannot be executed from the MVBasic command shell. Attempting to do so results in a MVBasic syntax error.
MATPARSE is the functional opposite of MATBUILD.
Examples
The following example illustrates the use of the MATPARSE statement:
   ! Dimension a static array
DIM MyArray(2,5)
   ! Create a dynamic array with 5 elements
MyDyn="Fred":@FM:"Barney":@FM:"Wilma":@FM:"Betty":@FM:"Pebbles"
   ! Assign dynamic array elements to the dimensioned static array
MATPARSE MyArray FROM MyDyn
   ! Display the number of elements parsed
CRT INMAT()
   ! Display static array element values
CRT MyArray(1,2); ! returns "Barney"
CRT MyArray(1,3); ! returns "Wilma"
The following example uses a start value of 2. It is otherwise identical to the previous example:
   ! Dimension a static array
DIM MyArray(3,5)
   ! Create a dynamic array with 5 elements
MyDyn="Fred":@FM:"Barney":@FM:"Wilma":@FM:"Betty":@FM:"Pebbles"
   ! Assign dynamic array elements to the dimensioned static array
MATPARSE MyArray,2 FROM MyDyn
   ! Display the number of elements parsed
CRT INMAT()
   ! Display static array element values
CRT MyArray(1,2); ! returns "Fred"
CRT MyArray(1,3); ! returns "Barney"
The following example uses Value Marks (@VM) as the dynamic array delimiters. It is otherwise identical to the first example:
   ! Dimension a static array
DIM MyArray(2,5)
   ! Create a dynamic array with 5 elements
MyDyn="Fred":@VM:"Barney":@VM:"Wilma":@VM:"Betty":@VM:"Pebbles"
   ! Assign dynamic array elements to the dimensioned static array
MATPARSE MyArray FROM MyDyn USING @VM
   ! Display the number of elements parsed
CRT INMAT()
   ! Display static array element values
CRT MyArray(1,2); ! returns "Barney"
CRT MyArray(1,3); ! returns "Wilma"
See Also