Product SiteDocumentation Site

A.5. LABEL Phrase

The LABEL phrase may be used to specify a name for the DO or LOOP. The can optionally be used for

Example A.9. Simple LOOP block with label

Loop label outer I=1 to 10 by 2
   ...
   if i > 5 then do label inner
      ...
      if a = b then leave inner
      ...
      if c = b then iterate outer
   end inner
   ...
   say i
end outer
/* Displays: "1" "3" "5" "7" */

In this example, the LEAVE instruction will exit the inner DO block. The ITERATE instruction will iterate the out LOOP instruction.
If a LABEL phrase is used on a DO or LOOP, it overrides any name derived from any control variable name. That is, if label is used, the control variable cannot be used on a LEAVE, ITERATE, or END instruction to identify the block. Only the label name is valid.