Skip to main content


Returns the value of the next subscript in a subscripted variable.




Argument Description
variable The array subscript to be used to determine the next existing subscript value.


$NEXT returns the value of the next subscript in the subscripted variable. It can be either a local or global subscripted array element. The value of the rightmost subscript must be a number whose value is -1 or greater. If you are using a naked global reference, the naked indicator must be defined.

$NEXT is an obsolete function that has been superseded by the $ORDER function. It is documented here only for completeness.


Do not use $NEXT in any new code. Use $ORDER in place of $NEXT to retrieve subscripts of an array.



$NEXT is similar to $ORDER. Both return the subscripts of the next sibling in collating order to the specified node. However, $NEXT and $ORDER have different start and failure codes, as follows:

Starting point -1 Null string
Failure code -1 Null String

See Also

$ORDER function

FeedbackOpens in a new tab