$ZPREVIOUS (legacy function)
Synopsis
$ZPREVIOUS(variable) $ZP(variable)
Parameter
Argument | Description |
---|---|
variable | Name of local or global array variable or the null string. It can be specified as a value, a variable, or an expression. |
Description
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.
As with $ORDER, you can use $ZPREVIOUS on both local and global variables.
Example
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
See Also
-
$ORDER function
-
$ZNEXT function
-
$ZREFERENCE special variable