Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples
Left Hand Pointer

$DPIECE

M[UMPS] by Example

Right Hand Pointer

Approved for inclusion in a future 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.

Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

Copyright © Standard Documents; 1977-2017 MUMPS Development Committee;
Copyright © Examples: 1995-2017 Ed de Moel;
Copyright © Annotations: 2003-2017 Jacquard Systems Research.

The information in this page is NOT authoritative and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an authoritative definition.

Some specifications are "approved for inclusion in a future standard". Note that the MUMPS Development Committee cannot guarantee that such future standards will indeed be published.

This page most recently updated on 28-Nov-2011, 20:33:03 .

For comments, contact Ed de Moel (demoel@jacquardsystems.com)