Case Statement - Siemens S7-1200 System Manual

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

Advertisement

7.8.9.3

CASE statement

Table 7- 116 Elements of the CASE statement
SCL
CASE "Test_Value" OF
"ValueList": Statement[; Statement, ...]
"ValueList": Statement[; Statement, ...]
[ELSE
Else-statement[; Else-statement, ...]]
END_CASE;
Table 7- 117 Parameters
Parameter
"Test_Value"
"ValueList"
Statement
Else-statement
The CASE statement is executed according to the following rules:
● The Test_value expression must return a value of the type Int.
● When a CASE statement is processed, the program checks whether the value of the
● If no match is found, the program section following ELSE is executed or no statement is
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG
Description
Required. Any numeric expression of data type Int
Required. A single value or a comma-separated list of values or ranges of values. (Use two
periods to define a range of values: 2..8) The following example illustrates the different
variants of the value list:
1: Statement_A;
2, 4: Statement _B;
3, 5..7,9: Statement _C;
Required. One or more statements that are executed when "Test_Value" matches any value
in the value list
Optional. One or more statements that are executed if no match with a value of the
"ValueList" stated matches
Test_value expression is contained within a specified list of values. If a match is found,
the statement component assigned to the list is executed.
executed if the ELSE branch does not exist.
7.8 Program control operations
Description
The CASE statement executes one of several
groups of statements, depending on the value
of an expression.
Basic instructions
269

Advertisement

Table of Contents
loading

Table of Contents