Approved for inclusion in a future ANSI M[UMPS] language standard.
This function works on substrings of strings that are specified as parameters. This function is intended to be used in conjunction with data structures that store multiple values in a single string. The main difference with the function $PIECE is that this function is capable of working on multiple substrings at the same time.
SET DLM="^"
SET X=$DPIECE("",DLM,A+3,B,,D,,,)
Stores values into a data record.
The record format specification relies on the function $PIECE to
define the record fields. The piece delimiter is the value of
DLM. The first parameter specifies the string in which
the substitution will occur (an empty string in this example). The
value of A+3 is used to replaced the first piece, the
value of B replaces the second piece, the third piece is
untouched (since the initial value was an empty string, this
piece will remain empty), the value of D replaces the
fourth piece.
The omitted parameters for the fifth through seventh pieces cause the record value to be modified in the sense that piece-separators for these pieces are inserted, but the pieces themselves will remain untouched (empty in this case).
SET DLM="^"
SET X=$DPIECE(X,DLM,A:5,,,$$ABC)
Stores values into a data record.
The value of local variable
X is the initial value of the data record into which
substitution will occur. The parameter A:5 indicates
that the value of A is to replace the fifth piece
(separated by the value of DLM).
Each parameter that follows the third parameter of the function $DPIECE is applied to the "next" piece, unless an explicit specification of a piece-counter redefines the current piece-number. Thus pieces 6 and 7 are left untouched (due to the omitted parameters), and piece number 8 is replaced by the value of $$ABC.
SET DLM="$"
SET $DPIECE(DLM,A,B:4,,D)=X
Extracts values out of a data record.
The value of local variable X is the data record that is being
accessed, and the values of some data fields will be extracted
and stored into other local variables. The value of the first
piece (separated by the value of DLM) will be stored in local
variable A; the value of the fourth piece will be stored in local
variable B, and the value of the sixth piece (note the omitted
parameter) will be stored in local variable D.
This document is © Ed de Moel, 1995-2005.
It is part of a book by Ed de Moel that is published under
the title "M[UMPS] by Example" (ISBN 0-918118-42-5).
Printed copies of the book are no longer available.