☜ | $PIECEDraft MDC Standard | ☞ |
This form is defined here with the aid of a function, NF, which is used for definitional purposes only, called find the position number following the mth occurrence.
NF(s , d , m) is defined, for strings s, d, and integer m, as follows: When d is the empty string, the result is zero. When m '> 0, the result is zero. When d is not a substring of s, i.e., when $Find(s , d) = 0, then the result is $Length(s) + $Length(d) + 1. Otherwise, NF(s , d , 1) = $Find(s , d). For m > 1, NF(s , d , m) = NF( $Extract( s , $Find( s , d), $Length(s) ), d , m - 1) + $Find(s , d) - 1. That is, NF extends $Find to give the position number of the character to the right of the mth occurrence of the string d in s. |
Let s be the value of expr1, and let d be the value of expr2. $Piece(s,d) returns the substring of s bounded on the right but not including the first (leftmost) occurrence of d.
$Piece(s , d) = $Extract(s , 0, NF(s , d ,1) - $Length(d) - 1).
$P[IECE] ( expr1 , expr2 , intexpr )
Let m be the integer value of intexpr. $Piece(s,d,m) returns the substring of s bounded by but not including the m–1th and the mth occurrence of d.
$Piece(s , d , m) = $Extract( s , NF(s , d , m - 1), NF(s , d , m) - $Length(d) - 1).
$P[IECE] ( expr1 , expr2 , intexpr1 , intexpr2 )
Let m be the integer value of intexpr1.Let n be the integer value of intexpr2. $Piece(s , d , m , n ) returns the substring of s bounded on the left but not including the m–1th occurrence of d in s, and bounded on the right but not including the nth occurrence of d in s.
$Piece(s , d , m , n ) = $Extract(s , NF(s , d , m - 1), NF(s , d , n ) - $Length(d) - 1).
Note that $Piece(s , d , m , m ) = $Piece(s , d , m ), and that $Piece(s , d ,1) = $Piece(s , d ).
Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.
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 15-Nov-2023, 13:11:13.
For comments, contact Ed de Moel (demoel@jacquardsystems.com)