Document Templates : DGL Statements : Control Flow Statements : EXIT Statement

EXIT Statement

Statement Syntax:

EXIT ;

The EXIT statement is relevant only inside FOR or WHILE loops. It results in an exit from the current loop to the statement after the loop construct or to the construct that contains the current loop.

Typically, a condition would be tested in a loop, and the exit would be based upon the evaluation of that condition.

For example, the following structure would continue the execution of the statements between the LOOP and END LOOP, depending on the value of the condition a > b.

The iterations go on as long as the status st is equal to 0. When st is not equal to stm_success, it causes the iterations to stop. The IF statement here is used to force an abnormal EXIT from within the WHILE loop.

The execution resumes at the next statement after the END LOOP.

WHILE a > b LOOP
md_id := stm_r_md (name , st) ;
IF st <> stm_success THEN
WRITE (’Illegal Status’) ;
EXIT ;
END IF ;
.
.
END LOOP ;