Attention
IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.
EXIT¶
The EXIT statement terminates execution of the innermost enclosing loop.
IEC 61131-3 |
Section 3.3.2.4 |
Support |
Supported |
Syntax¶
EXIT ;
Description¶
EXIT immediately breaks out of the innermost FOR, WHILE, or
REPEAT loop. Execution continues with the first statement after the loop’s
closing keyword (END_FOR, END_WHILE, or END_REPEAT).
If EXIT appears inside nested loops, only the innermost loop is
terminated.
Example¶
PROGRAM main
VAR
i : INT;
found : BOOL := FALSE;
data : INT := 42;
END_VAR
FOR i := 1 TO 100 DO
IF i = data THEN
found := TRUE;
EXIT;
END_IF;
END_FOR;
END_PROGRAM