|
|
|
|
|
|
|
☜ | SET1990 Version of ANSI Standard | ☞ |
2.6.17 Set
S[ET] postcond SP L setargument
See 2.5.1 for the definition of postcond. See section 1
for the definition of L.
See 2.2.2.2 for the definition of glvn. See 2.3 for the
definition of expr. See 2.2 for the definition of
expratom. See section 1 for the definition of V.
See section 1 for the definition of L.
See 2.2.2.2 for the definition of glvn. See 2.3 for the
definition of expr. See 2.2.4.1 for the definition of
intexpr.
Set is the general means both for explicitly assigning
values to variables, and for substituting new values in pieces of
a variable. Each setargument computes one value, defined
by its expr. That value is then either assigned to each of
one or more variables, or it is substituted for one or more
pieces of a variable’s current value. Each variable is named by
one glvn.
Each setargument is executed one at a time in
left-to-right order. The execution of a setargument occurs
in the following order.
- One of the following two operations is performed:
- If the portion of the setargument to
the left of the = consists of one or more glvns, the
glvns are scanned in left-to-right order and all
subscripts are evaluated, in left-to-right order within each
glvn.
- If the portion of the setargument to
the left of the = consists of a setpiece, the glvn
that is the first argument of the setpiece is scanned in
left-to-right order and all subscripts are evaluated in
left-to-right order within the glvn, and then the remaining
arguments of the setpiece are evaluated in left-to-right
order.
- The expr to the right of the = is evaluated.
- One of the following two operations is performed.
- If the left-hand side of the set is one or
more glvns, the value of expr is given to each
glvn, in left-to-right order. (See 2.2.2.3 for a
description of the value assignment operation).
- If the left-hand side of the set is a
setpiece, of the form
$P(glvn,d,m,n),
the value of expr replaces the mth through the
nth pieces of the current value of the glvn, where
the value of
d is the piece delimiter. Note that both
m and n are optional. If neither is present, then
m = n = 1; if only m is present, then
n = m. If glvn has no current value, the
empty string is used as its current value. Note that the current
value of glvn is obtained just prior to replacing it. That
is, the other arguments of setpiece are evaluated in
left-to-right order, and the expr to the right of the = is
evaluated prior to obtaining the value of glvn.
Let s be the current value of
glvn, k be the number of occurrences of d in
s, that is, k = max(0,$L(s,d)
- 1), and t be the value of expr. The following
cases are defined, using the concatenation operator _ of
2.3.5.
- m > n or n < 1.
The glvn is not changed and does not change the
naked indicator.
- n '< m–1 > k.
The value in glvn is replaced by
s_F(m–1-k)_t, where F(x)
denotes a string of x occurrences of d, when
x > 0; otherwise, F(x) = "". In either case,
glvn affects the naked indicator.
- m–1 '> k < n.
The value in glvn is replaced by
$P(s,d,1,m–1)_F(min(m–1,1))_t.
- Otherwise,
The value in
glvn is replaced by
$P(s,d,m–1)_F(min(m–1,1))_t_d_$P(s,d,n+1,k+1).
If the glvn is a global variable, the naked indicator
is set at the time that the glvn is given its value. If
the glvn is a naked reference, the reference to the
naked indicator to determine the name and initial subscript sequence
occurs just prior to the time that the glvn is given its
value.
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.
This page most recently updated on 15-Nov-2023, 18:56:15.
For comments, contact Ed de Moel (demoel@jacquardsystems.com)