BREAK and CONTINUE


 

The BREAK and CONTINUE verbs alter the program execution sequence. BREAK terminates the currently active LOOP/REPEAT, even if there are several levels of active IF/ENDIF instructions. CONTINUE forces execution to resume at the currently active LOOP instruction even if there are several levels of IF/ENDIF instructions. These structures use the following formats:

 

(1)

[label]

BREAK

 

(2)

[label]

BREAK

IF [NOT] {condition}

(3)

[label]

CONTINUE

 

(4)

[label]

CONTINUE

IF [NOT] {condition}

 

Where:

label

Optional. A Program Execution Label.

condition

Required. A valid check for a Flag or Expression.

Flags Affected: Function Key Flag

Note the following:

  1. The Function Flag is reset if tested and it was true.

  2. If a FILEPI instruction is active, the FILEPI count is not decremented by this instruction.

  3. BREAK and CONTINUE statements must be physically located within the scope of a LOOP/REPEAT structure.

 

 

Example 1:

 

A

FORM

2

  

LOOP

 

  

KEYIN

*N,"ENTER A: ",A;

  

BREAK

IF F1

  

DISPLAY

*N,"VALUE: ",A;

  

REPEAT

 

 

The LOOP is terminated when the F1 function flag is TRUE.

 

Example 2:

 

A

FORM

2

  

LOOP

 

  

KEYIN

*N,"ENTER A: ",A;

  

BREAK

IF F1

  

CONTINUE

IF (A=5)

  

DISPLAY

*N,"VALUE: ",A;

  

REPEAT

 

 

The CONTINUE causes the program execution to branch back to the LOOP if the operator entered '5' into 'A'.

 

 

See Also: LOOP/REPEAT, Program Control Instructions

 



PL/B Language Reference BRANCHF CACHELIST and CACHELISTEND