Description, Arithmetic status flags, Fault conditions – Rockwell Automation Logix5000 Controllers Structured Text Programming Manual User Manual
Page 29

Publication 1756-PM007D-EN-P - November 2012
29
Program Structured Text Chapter 1
Description:
The syntax is:
These diagrams show how a FOR...DO loop executes and how an EXIT
statement leaves the loop early.
Arithmetic Status Flags:
Not affected
Fault Conditions:
FOR count := initial_value
TO final_value
Optional {
BY increment
If you don’t specify an increment, the loop
increments by 1.
DO
<statement>;
Optional
IF bool_expression 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_FOR;
statement 1
statement 2
statement 3
Done x number
of times?
No
Yes
Rest of the routine
statement 1
statement 2
statement 3
Done x number
of times?
no
Yes
Rest of the routine
Yes
No
The FOR…DO loop executes a specific
number of times.
To stop the loop before the count reaches the last
value, use an EXIT statement.
A major fault will occur if
Fault type
Fault code
The construct loops too long
6
1