11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ExampleThe following example uses a WHILE loop to repeatedly call $ZORDER to traverse a seriesof 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 }QUITThe 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 thatpoint. 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 ineach successive node. It then runs out of nodes and generates the following error: ^||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• $ORDER function• $QUERY function• $ZORDER function• $ZERROR special variable$ZORDER<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 481

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!