Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

SET

1984 Version of ANSI Standard

3.6.15 SET

S[ET] postcond Space L setargument

    setargument::=







setpiece
glvn
(L glvn )



= expr

@ expratom V L setargument





    setpiece::= $P[IECE] ( glvn , expr1 [ , intexpr2 [ , intexpr3 ] ] )

See also the transition diagram for setpiece.

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

  1. 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.
  2. The expr to the right of the = is evaluated.
  3. One of the following two operations is performed.
    1. 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. For each subscripted glvn of the form
      N(v1, v2, ..., vn)
      each variable M whose name is of the form
      N(v1, v2, ..., vm)
      for all m < n, as well as the unsubscripted variable N, will be affected as follows.
      1. If M already has a "pointer", that is, if $D(M) has a value of 10 or 11, no change is made to the value of $D(M).
      2. If M has no pointer, that is, if $D(M) has a value of 0 or 1, then it is given a pointer. If $D(M) was 0 it becomes 10, and if $D(M) was 1 it becomes 11.
      The $D value of glvn itself is changed as follows:
      0   becomes   1
      10   becomes   11
      1   remains   1
      11   remains   11
      That is, the pointer status is not altered, but the variable’s value may become defined.
    2. 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 Sect. 3.3.5.
      1. m > n or n < 1.
        The glvn is not changed and glvn does not change the naked indicator.
      2. 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.
      3. m–1 ≤ k < n.
        The value in glvn is replaced by $P(s,d,1,m–1) F(min(m–1,1)) t.
      4. 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.

See also the transition diagram for Set.

Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

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)