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

$NEXT

1984 Version of ANSI Standard

3.2.8 Functions function

$N[EXT]( glvn )

is included for backward compatibility. The use of the $ORDER function is strongly encouraged in place of $NEXT, as the two functions perform the same operation except for the different starting and ending condition of $NEXT. $N returns a value which is a subscript according to a subscript ordering sequence. This ordering sequence is specified below with the aid of a function, CO, which is used for definitional purposes only, to establish the collating sequence.

CO(s,t) is defined, for strings s and t, as follows:

When t follows s in the ordering sequence, CO(s,t) returns t. Otherwise, CO(s,t) returns s.

Let m and n be strings satisfying the definition of numeric data values (Section 3.2.4.1), and u and v be nonempty strings which do not satisfy this definition. The following cases define the ordering sequence:

  1. CO("",s) = s.
  2. CO(m,n) = n if n > m; otherwise, CO(m,n) = m.
  3. CO(m,u) = u.
  4. CO(u,v) = v if v ] u; otherwise, CO(u,v) = u.

In words, all strings follow the empty string, numerics collate in numeric order, numerics precede nonnumeric strings, and nonnumeric strings are ordered by the conventional ASCII collating sequence.

Only subscripted forms of lvn and gvn are permitted. Let lvn or gvn be of the form Name(s1, s2, ..., sn). If sn is –1, let A be the set of all subscripts. If sn is not –1, let A be the set of all subscripts that follow sn; that is, for all s in A:

  1. CO(sn,s) = s and
  2. $D(Name(s1, s2, ..., sn–1, s)) is not zero.

Then $N(Name(s1, s2, ..., sn)) returns that value t in A such that CO(t,s) = s for all s not equal to t; that is, all other subscripts which follow sn also follow t.

If no such t exists, –1 is returned.

Note that $N will return ambiguous results for lvn and gvn arrays which have negative numeric subscript values.

See also the transition diagram for $Next.

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 13-Sep-2014, 08:49:16.

For comments, contact Ed de Moel (demoel@jacquardsystems.com)