Basic instructions
7.8 Program control operations
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG
269
Table 7- 116 Elements of the CASE statement
"ValueList": Statement[; Statement, ...]
"ValueList": Statement[; Statement, ...]
[ELSE
Else-statement[; Else-statement, ...]]
The CASE statement executes one of several
groups of statements, depending on the value
of an expression.
Table 7- 117 Parameters
Required. Any numeric expression of data type Int
"ValueList" 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;
Statement Required. One or more statements that are executed when "Test_Value" matches any value
Else-statement Optional. One or more statements that are executed if no match with a value of the
"ValueList" stated matches
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
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.
● If no match is found, the program section following ELSE is executed or no statement is
executed if the ELSE branch does not exist.