MUMPS Functions $PIECE

From VistApedia
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.