ST instruction CASE

The CASE instruction is used to group multiple conditional instructions with the same conditional variable in a construct.

Syntax:

CASE <Var1> OF
<value1>:<instruction1>
<value2>:<instruction2>
<value3, value4, value5>:<instruction3>
<value6 ... value10>:<instruction4>
...
<value n>:<instruction n>
{ELSE <ELSE-instruction>}
END_CASE;

The section inside the curly braces {} is optional.

Processing scheme of a CASE instruction:

Example:

CASE nVar OF 
     1,5 : bVar1 := TRUE; 
         bVar3 := FALSE; 

     2 : bVar2 := FALSE; 
         bVar3 := TRUE; 

10..20 : bVar1 := TRUE; 
         bVar3 := TRUE; 
ELSE 
         bVar1 := NOT bVar1; 
         bVar2 := bVar1 OR bVar2; 
END_CASE;