MUMPS Functions $PIECE

From VistApedia
Revision as of 20:11, 9 February 2010 by Ssw0213 (talk | contribs)
(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.