The format for the $QUERY function is:
$Q[UERY](glvn)
set ^X(1,2,3)="123" set ^X(1,2,3,7)="1237" set ^X(1,2,4)="124" set ^X(1,2,5,9)="1259" set ^X(1,6)="16" set ^X("B",1)="AB"
The tree diagram below represents the structure produced by the preceding routine.
set y="^X" for set y=$query(@y) quit:y="" write !,y,"=",@y
^X(1,2,3)=123 ^X(1,2,3,7)=1237 ^X(1,2,4)=124 ^X(1,2,5,9)=1259 ^X(1,6)=16 ^X("B",1)=AB
GTM>zwrite lcl lcl("")=1 lcl(1)=1 lcl(1,2)=2 lcl(1,2,"")=3 lcl(1,2,"","")=4 lcl(1,2,"","",4)=5 lcl(1,2,0)=6 lcl(1,2,"abc",5)=7 lcl("x")=1 GTM>set y="lcl" GTM>for set y=$query(@y) quit:y="" write !,y,"=",@y
This example produces the results:
lcl("")=1 lcl(1)=1 lcl(1,2)=2 lcl(1,2,"")=3 lcl(1,2,"","")=4 lcl(1,2,"","",4)=5 lcl(1,2,0)=6 lcl(1,2,"abc",5)=7 lcl("x")=1