Description
The EXIT
instruction is used to terminate repeat instructions
(FOR
, WHILE
, REPEAT
) before the end condition has been met.
If the EXIT
instruction is within a nested repetition, the innermost loop (in
which EXIT
is situated) is left. Next, the first
instruction following the loop end (END_FOR
, END_WHILE
or END_REPEAT
) is executed.
Example EXIT
If FLAG
has the value 0, SUM
will be 15 following the execution of the instructions.
If FLAG
has the value 1, SUM
will be 6 following
the execution of the instructions.
SUM := 0 ;
FOR I := 1 TO 3 DO
FOR J := 1 TO 2 DO
IF FLAG=1 THEN EXIT ;
END_IF ;
SUM := SUM + J ;
END_FOR ;
SUM := SUM + I ;
END_FOR ;