Exit Statement - Siemens SIMATIC S7 System Manual

Hide thumbs Also See for SIMATIC S7:
Table of Contents

Advertisement

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
● In a FOR statement, the control variable is incremented by the specified increment
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;
END_FOR;
7.8.8

EXIT statement

Table 7- 104 Exit instruction
SCL
Description
An EXIT statement is used to exit a loop (FOR, WHILE or REPEAT) at any point, regardless of whether
EXIT
the terminate condition is satisfied.
The EXIT statement executes according to the following rules:
● This statement causes the repetition statement immediately surrounding the exit
● Execution of the program is continued after the end of the loop (for example after
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;
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
executed again or the iteration statement is exited and the statement immediately
following is executed.
immediately after a CONTINUE statement.
p := part / value[i] * 100;
s := INT_TO_STRING(p);
percent=CONCAT(IN1:=s, IN2:="%");
statement to be exited immediately.
END_FOR).
100BBasic instructions
7.8 Program control
215

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the SIMATIC S7 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Simatic s7-1200

Table of Contents

Save PDF