While…do, Operands, Description – Rockwell Automation Logix5000 Controllers Structured Text Programming Manual User Manual

Page 31

Advertising
background image

Publication 1756-PM007D-EN-P - November 2012

31

Program Structured Text Chapter 1

WHILE…DO

Use the WHILE…DO loop to keep doing something as long as certain
conditions are true.

Operands:

Structured Text

Description:

The syntax is:

Operand

Type

Format

Enter

bool_
expression

BOOL

Tag

Expression

BOOL tag or expression that evaluates to
a BOOL value

WHILE bool_expression DO

<statement>;

END_WHILE;

IMPORTANT

Make sure that you do not iterate within the loop too many times in a single
scan.

•

The controller does not execute any other statements in the routine until
it completes the loop.

•

If the time that it takes to complete the loop is greater than the
watchdog timer for the task, a major fault occurs.

•

Consider using a different construct, such as IF...THEN.

WHILE bool_expression1 DO

<statement>;

Statements to execute while
bool_expression1 is true

Optional

IF bool_expression2 THEN

EXIT;

If there are conditions when you want to
exit the loop early, use other statements,
such as an IF...THEN construct, to
condition an EXIT statement.

END_IF;

END_WHILE;

Advertising