Returns the previous array node subscript for the specified variable.
This page describes the legacy function
$ZPREVIOUS. It is described here for compatibility with legacy applications. Use of
$ZPREVIOUS is discouraged. Rather, use the form
$ORDER(
variable,-1).
$ZPREVIOUS returns the previous array node subscript for the specified variable.
$ZPREVIOUS is similar to the
$ORDER function, except that it returns the previous, rather that the next, subscript in the collation sequence.
You can use it to traverse a global in reverse subscript order. To start at the last subscript on a given level, specify the null string for the subscript reference.
$ZPREVIOUS returns the null string after it returns the first subscript on the root level.
Given the array node definitions shown, and starting with the last subscript,
$ZPREVIOUS returns the following results:
SET ^ABC(1)=1
SET ^ABC(2)=2
SET ^ABC(3)=3
SET x=$ZPREVIOUS(^ABC("")) ; 3
WRITE !,"Third is ",x
SET x=$ZPREVIOUS(^ABC(x)) ; 2
WRITE !,"Second is ",x
SET x=$ZPREVIOUS(^ABC(x)) ; 1
WRITE !,"First is ",x
SET x=$ZPREVIOUS(^ABC(x)) ; ""
WRITE !,"Top is ",x