11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

For unsubscripted local variables, $ORDER returns variables in direction 1 (next) orderonly; you cannot specify a direction of –1 (previous).• $ORDER(variable,direction,target) returns the subscript for the variable, and sets targetto its current data value. This can be either the next or the previous subscript for a subscriptedvariable, depending on the direction setting. For an unsubscripted local variable,direction must be set to 1 to return the current data value to target. The target parametercannot be used with structured system variables (SSVNs) such as ^$ROUTINE.ExamplesThe following example lists the name and value of the next defined local variables aftervariable a1:SET a="best",a1="prime",aa="choice",b="good",c="utility grade"WRITE !,$ORDER(a1,1,target),!,targetThe following example returns 1, the first subscript in ^X. It sets the naked indicator to thefirst level.SET ^X(1,2,3)="1", ^X(2)="2"WRITE $ORDER(^X(-1))The following example returns 2, the next subscript on the single subscripted level. (The nodeyou specify in the argument need not exist.) The naked indicator is still set to the first level.SET ^X(1,2,3)="1",^X(2)="2"WRITE $ORDER(^X(1))The following example returns 2, the first subscript on the two-subscript level. The nakedindicator is now set at the second level.SET ^X(1,2,3)="1",^X(2)="2"WRITE $ORDER(^X(1,-1))The following example uses $ORDER to list all of the primary subscripts in the ^data global:SET ^data(1)="a",^data(3)="c",^data(7)="g"// Get first subscriptSET key=$ORDER(^data(""))WHILE (key'="") {WRITE key,!// Get next subscriptSET key = $ORDER(^data(key))}$ORDER<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 277

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

Saved successfully!

Ooh no, something went wrong!