If...then, Operands, Description – Rockwell Automation Logix5000 Controllers Structured Text Programming Manual User Manual

Page 22

Advertising
background image

22

Publication 1756-PM007D-EN-P - November 2012

Chapter 1 Program Structured Text

IF...THEN

Use IF…THEN to do something if or when specific conditions occur.

Operands:

Structured Text

Description:

The syntax is:

To use ELSIF or ELSE, follow these guidelines.

1. To select from several possible groups of statements, add one or more

ELSIF statements.

Each ELSIF represents an alternative path.

Specify as many ELSIF paths as you need.

The controller executes the first true IF or ELSIF and skips the rest
of the ELSIFs and the ELSE.

2. To do something when all of the IF or ELSIF conditions are false, add

an ELSE statement.

Operand

Type

Format

Enter

bool_
expression

BOOL

Tag

Expression

BOOL tag or expression that evaluates to
a BOOL value (BOOL expression)

IF bool_expression THEN

<statement>;

END_IF;

IF bool_expression1 THEN

<statement >;

Statements to execute when
bool_expression1 is true

.
.
.

Optional

ELSIF bool_expression2 THEN

<statement>;

Statements to execute when
bool_expression2 is true

.
.
.

Optional

ELSE

<statement>;

Statements to execute when
both expressions are false

.
.
.

END_IF;

Advertising