Statement - switch between enumerated statements.

Syntax

   CASE <DINT expression> OF
    <value> :
        <statements>
    <value> , <value> :
        <statements>;
    <value> .. <value> :
        <statements>;
   ELSE
        <statements>
   END_CASE;

Remarks

All enumerated values correspond to the evaluation of the DINT expression and are possible cases in the execution of the statements. The statements specified after the ELSE keyword are executed if the expression takes a value that is not enumerated in the switch. For each case, you must specify either a value, or a list of possible values separated by comas (",") or a range of values specified by a "min .. max" interval. You must enter space characters before and after the ".." separator.

ST Language

example Example

This example checks the first prime numbers:
CASE iNumber OF
0 :
   Alarm := TRUE;
   AlarmText := '0 gives no result';
1 .. 3, 5 :
   bPrime := TRUE;
4, 6 :
   bPrime := FALSE;
ELSE
   Alarm := TRUE;
   AlarmText := 'I don't know after 6 !';
END_CASE;

FBD Language

Not available.

LD Language

Not available.

Fixed_Image See also

IF  WHILE  REPEAT  FOR  EXIT

CASE OF ELSE END_CASE

IEC 61131-3 Automation platform > Programming - Reference guide > Basic Operations > CASE OF ELSE END_CASE

Previous chapterNext chapter


Created with the Personal Edition of HelpNDoc: Leave the tedious WinHelp HLP to CHM conversion process behind with HelpNDoc