CYCLE (go to top of loop)

Top  Previous  Next

 

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:

Event:Iconize

Event:Maximize

Event:Move

Event:PreAlertKey

Event:Restore

Event:Size

Event:Contracting

Event:Expanding

EVENT:CloseDown

EVENT:CloseWindow

EVENT:DDEPoke

EVENT:DDEExecute

 

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:

LOOP

BREAK

ACCEPT