Continue Statement; Exit Statement - Siemens S7-1200 System Manual

Hide thumbs Also See for S7-1200:
Table of Contents

Advertisement

7.8.9.7

CONTINUE statement

Table 7- 124 CONTINUE statement
SCL
CONTINUE
Statement;
;
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 i := 0 TO 10 DO
IF value[i] = 0 THEN CONTINUE; END_IF;
END_FOR;
7.8.9.8

EXIT statement

Table 7- 125 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
● Execution of the program is continued after the end of the loop (for example after
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG
Description
The CONTINUE statement skips the subsequent statements of a program loop (FOR,
WHILE, REPEAT) and continues the loop with the examination of whether the condition is
met for termination. If this is not the case, the loop continues.
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).
Basic instructions
7.8 Program control operations
273

Advertisement

Table of Contents
loading

Table of Contents