Navigation: Language Reference > 12 - Execution Control > Execution Control Statements >====== CYCLE (go to top of loop) ====== | |
CYCLE [ label ]
CYCLE | Transfers control back to the top of a LOOP or ACCEPT structure. |
label | The label on the LOOP or ACCEPT statement to which to return. This must be the label of a nested loop structure containing the CYCLE statement. |
The CYCLE statement passes control immediately back to the top of the LOOP or ACCEPT loop. CYCLE may only be used in a LOOP or ACCEPT loop structure. The use of the optional label argument allows you to cleanly go back to the top of outer levels of nested loops, eliminating one common use of GOTO.
In an ACCEPT loop, for certain events, CYCLE terminates an automatic action before it is performed. This behavior is documented for each event so affected:
Example:
SET(MasterFile) !Point to first record
LOOP !Process all the records
NEXT(MasterFile) !read a record
IF ERRORCODE() THEN BREAK. !Get out of loop at end of file
DO MatchMaster !check for a match
IF NoMatch !if match not found
CYCLE !jump to top of loop
END
DO TransVal !validate the transaction
PUT(MasterFile) !write the record
END
Loop1 LOOP !Loop1 is the label
DO ParentProcess
Loop2 LOOP !Loop2 is the label
DO ChildProcess
IF SomeCondition
CYCLE Loop1 !Cycle back to top of outer loop
END
END
END
See Also: