Example:
GTM>DO ^%RD
This example invokes the routine directory utility program (%RD) from Direct Mode. The caret symbol (^) specifies that the DO command invokes %RD as an external routine.
Example:
GTM>DO A(3)
This example invokes the subroutine at label A and passes the value 3 as a parameter. Because the DO argument does not have a caret symbol (^), it identifies A as a label in the current routine.
Example:
Label A; SET di="" U outfile FOR SET di=$O(^div(di)) Q:di="" D PREP D D POST .SET de="",(nr,gr)=0 .WRITE "Division ",di,! F S de=$O(^de(di,de)) Q:de="" D ..WRITE "Department ",de," Gross Rev: ",^grev(di,de),! ..WRITE "Department ",de," Net Rev: ",^nrev(di,de),! ..SET gr=gr+^grev(di,de),nr=nr+^nrev(di,de) .W "Division Gross Rev: ",gr,!,"Division Net Rev: ",nr,! DO PRINT^OUTPUT(outfile) QUIT
This routine first uses a DO with a label argument (PREP) to do some pre-processing. Then, it uses an argumentless DO to loop through each division of a company to format a report. Within the first argumentless DO, a second argumentless DO (line 4) loops through and formats each department within a division. After the processing of all departments, control returns to the first argumentless DO, which prints a summary of the division. Following processing of all divisions, a DO with a label argument (POST) does some post-processing. Finally, at the next-to-last line, the routine uses a DO that invokes a subroutine at a label (PRINT) in an external routine (^OUTPUT), passing the name of the output file (outfile) as a parameter.