EXITLOOP

Terminate a loop

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
EXITLOOP

Discussion

The EXITLOOP statement terminates a looping statement (such as DO FOREVER, FOR, REPEAT, and WHILE). After terminating the loop, control is transferred to the statement immediately following the looping statement.

Examples

The following subroutine prints a large report and checks after each page prints to see if the user typed a “Q” to quit printing. See NEXTLOOP for an example that demonstrates the difference between the NEXTLOOP, EXITLOOP, and EXIT statements.

subroutine prnt_rpt
    a_file      ,a
    a_data      ,a
external function
    get_pg      ,i
record
    page        ,d3
    input       ,a1
proc
    page = 1
    repeat
      begin
        if (.not. %get_pg(page, a_data))
            exitloop
        xcall prnt_pg(a_data)
        if (%ttsts)
          begin
            accept(TTCHN, input)
            if (input .eq. 'Q')
              exitloop
          end
        incr page
      end
    xreturn
endsubroutine