Chapter 8. Structured Text (ST) Programming
8.2.10
Exit Statement
The EXIT statement is used to terminate and exit from a loop (FOR, WHILE, REPEAT) before it would
otherwise terminate. Program execution resumes with the statement following the loop terminator
(END_FOR, END_WHILE, END_REPEAT). An EXIT statement is typically used within an IF statement.
Format
EXIT;
Where:
ConditionForExiting
Example
The following code fragment shows the operation of the EXIT statement. When the variable number
equals 10, the WHILE loop is exited and execution continues with the statement immediately
following END_WHILE.
while (1) do
a := a + 1;
IF (a = 10) THEN
EXIT;
END_IF;
END_WHILE;
382
PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual
An expression that determines whether to terminate early.
GFK-2950C