100BBasic instructions
7.8 Program control
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
215
The CONTINUE statement executes according to the following rules:
●
This statement immediately terminates execution of a loop body.
●
Depending on whether the condition for repeating the loop is satisfied or not the body is
executed again or the iteration statement is exited and the statement immediately
following is executed.
●
In a FOR statement, the control variable is incremented by the specified increment
immediately after a CONTINUE statement.
Use the CONTINUE statement only within a loop. In nested loops CONTINUE always refers
to the loop that includes it immediately. CONTINUE is typically used in conjunction with an IF
statement.
If the loop is to exit regardless of the termination test, use the EXIT statement.
The following example shows the use of the CONTINUE statement to avoid a division-by-0
error when calculating the percentage of a value:
FOR x = 0 TO 10 DO
IF value[i] = 0 THEN CONTINUE; END_IF;
p := part / value[i] * 100;
s := INT_TO_STRING(p);
percent=CONCAT(IN1:=s, IN2:="%");
END_FOR;
7.8.8
EXIT statement
Table 7- 104 Exit instruction
SCL
Description
EXIT
An EXIT statement is used to exit a loop (FOR, WHILE or REPEAT) at any point, regardless of whether
the terminate condition is satisfied.
The EXIT statement executes according to the following rules:
●
This statement causes the repetition statement immediately surrounding the exit
statement to be exited immediately.
●
Execution of the program is continued after the end of the loop (for example after
END_FOR).
Use the EXIT statement within a loop. In nested loops, the EXIT statement returns the
processing to the next higher nesting level.
FOR i = 0 TO 10 DO
CASE value[i, 0] OF
1..10: value [i, 1]:="A";
11..40:= value [i, 1]:="B";
41..100:= value [i, 1]:="C";
ELSE
EXIT;
END_CASE;
END_FOR;