MUMPS Functions $PIECE

From VistApedia
Revision as of 13:54, 1 April 2012 by NeilArmstrong (talk | contribs) (Added a glossary link to record~)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The $PIECE function returns a substring delimited by a specified string delimiter made up of one or more characters. In M, $PIECE() returns a logical field from a logical Record.

$PIECE() provides a tool for efficiently using values that contain multiple elements or fields, each of which may be variable in length.

Example:

GTM> FOR i=0:1:3 WRITE !,$PIECE("1 2"," ",i),"<" 
< 
1< 
2< 
< 
GTM> 

This loop displays the result of $PIECE(), specifying a space as a delimiter, a piece position "before," first and second, and "after" the string.