Caché ObjectScript Reference
[Back] [Next]
Go to:

Contains the value of the next global node.
$ZORDER contains the value of the next global node (in $QUERY sequence, not $ORDER sequence), after the current global reference. If there is no next global node, accessing $ZORDER results in an <UNDEFINED> error, indicating the last global successfully accessed by $ZORDER. For further details on <UNDEFINED> errors, refer to $ZERROR.
This special variable cannot be modified using the SET command. Attempting to do so results in a <SYNTAX> error.
The following example uses a WHILE loop to repeatedly call $ZORDER to traverse a series of subscript nodes:
  SET ^||a="groceries"
  SET ^||a(1)="fruit"
  SET ^||a(1,1)="apples"
  SET ^||a(1,2)="oranges"
  SET ^||a(3)="nuts"
  SET ^||a(3,1)="peanuts"
  SET ^||a(2)="vegetables"
  SET ^||a(2,1)="lettuce"
  SET ^||a(2,2)="tomatoes"
  SET ^||a(2,1,1)="iceberg"
  SET ^||a(2,1,2)="romaine"
  SET $ZERROR="unset"
  WRITE !,"last referenced: ",^||a(1,1)
  WHILE $ZERROR="unset" {
      WRITE !,$ZORDER }
The above example starts with the last-referenced global (in this case, process-private globals): ^||a(1,1). $ZORDER does not contain the value of ^||a(1,1), but works forward from that point. Calls to $ZORDER traverse the subscript tree nodes in the following order: (1,2), (2), (2,1), (2,1,1), (2,1,2), (2,2), (3), (3,1). Each WRITE $ZORDER displays the data value in each successive node. It then runs out of nodes and generates the following error: <UNDEFINED> ^||a(3,1). Note that ^||a(3,1) is not undefined; it is specified because $ZORDER could not find another global after this one.
See Also