ST Statement ‘CASE’ΒΆ

Use this dialog box for pooling several conditional instructions containing the same condition variable into 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 within the curly brackets {} is optional.

Processing scheme of a CASE instruction.

Example

CASE iVar 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;