Case...of, Operands, Description – Rockwell Automation Logix5000 Controllers Structured Text Programming Manual User Manual

Page 25

Advertising
background image

Publication 1756-PM007D-EN-P - November 2012

25

Program Structured Text Chapter 1

CASE...OF

Use CASE to select what to do based on a numerical value.

Operands:

Structured Text

Description:

The syntax is:

Operand

Type

Format

Enter

numeric_

expression

SINT

INT

DINT

REAL

Tag

Expression

Tag or expression that evaluates to a
number (numeric expression)

selector

SINT

INT

DINT

REAL

Immediate

Same type as

numeric_expression

IMPORTANT

If you use REAL values, use a range of values for a selector
because a REAL value is more likely to be within a range of
values than an exact match of one, specific value.

CASE numeric_expression OF

selector1: statement;

selectorN: statement;

ELSE

statement;

END_CASE;

CASE numeric_expression OF

Specify as many

alternative selector

values (paths) as you

need

selector1 :

<statement>;

.
.
.

Statements to execute when
numeric_expression = selector1

selector2 :

<statement>;

.
.
.

Statements to execute when
numeric_expression = selector2

selector3 :

<statement>;

.
.
.

Statements to execute when
numeric_expression = selector3

Advertising