Skip to content

$Next()

$Next()

Returns the next subscripted local or global variable name in collation sequence within the array level specified by its argument.

$NEXT() has been replaced by $ORDER(). $NEXT has been retained in the current standard only for compatibility with earlier versions of the standard. $NEXT() is similar to $ORDER(). However, $NEXT() has the deficiency that when it encounters negative one (-1) as a subscript, it returns the same result as when it finds no other data at the level. This deficiency is particularly disruptive because it occurs in the middle of the M collating sequence.

[Caution]Caution
As $NEXT() has been removed from the standard in the MDC, you should use $ORDER.

The format for the $NEXT function is:

$N[EXT](glvn)
  • The subscripted global or local variable name specifies the node following which $NEXT() searches for the next node with data and/or descendants; the number of subscripts contained in the argument implicitly defines the array level.
  • If $NEXT() finds no node at the specified level after the specified global or local variable, it returns negative one (-1).
  • If the last subscript in the subscripted global or local variable name is null or negative one (-1), $NEXT() returns the first node at the specified level.