100BBasic instructions
7.8 Program control
S7-1200 Programmable controller
216
System Manual, 11/2011, A5E02486680-05
7.8.9
GOTO statement
Table 7- 105 GOTO statement
SCL
Description
GOTO JumpLabel
Statement;
... ;
JumpLabel: Statement;
The GOTO statement skips over statements by jumping to a label in the same
block.
The jump label ("JumpLabel") and the GOTO statement must be in the same block.
The name of a jump label can only be assigned once within a block. Each jump
label can be the target of several GOTO statements.
It is not possible to jump to a loop section (FOR, WHILE or REPEAT). It is possible to jump
from within a loop.
In the following example: Depending on the value of the "Tag_value" operand, the execution
of the program resumes at the point defined by the corresponding jump label. If "Tag_value"
equals 2, the program execution resumes at the jump label "MyLabel2" and skips
"MyLabel1".
CASE "Tag_value" OF
1 : GOTO MyLabel1;
2 : GOTO MyLabel2;
ELSE GOTO MYLabel3
END_CASE;
MyLabel1: "Tag_1" := 1;
MyLabel2: "Tag_2" := 1;
MyLabel3: "Tag_4" := 1;
7.8.10
RETURN statement
Table 7- 106 Return instruction
SCL
Description
Return;
The Return instruction exits the code block being executed without conditions. Program
execution returns to the calling block or to the operating system (when exiting an OB).
Example of a Return instruction:
IF "Error" <> 0 THEN
Return;
END_IF
Note
After executing the last instruction, the code block automatically returns to the calling block.
Do not insert a Return instruction at the end of the code block.