682 Rockwell Automation Publication 1756-RM003N-EN-P - October 2011
Appendix C Structured Text Programming
The table summarizes different combinations of IF, THEN, ELSIF,
and ELSE.
Arithmetic Status Flags Not affected
Fault Conditions: None
Example 1: IF…THEN
Example 2: IF…THEN…ELSE
If you want to And Use this construct
Do something if or when conditions are
true
Do nothing if conditions are false IF…THEN
Do something else if conditions are false IF…THEN…ELSE
Choose from alternative statements (or
groups of statements) based on input
conditions
Do nothing if conditions are false IF…THEN…ELSIF
Assign default statements if all conditions
are false
IF…THEN…ELSIF…ELSE
If you want this Enter this structured text
IF rejects > 3 then IF rejects > 3 THEN
conveyor = off (0) conveyor := 0;
alarm = on (1) alarm := 1;
END_IF;
If you want this Enter this structured text
If conveyor direction contact = forward (1) then IF conveyor_direction THEN
light = off light := 0;
Otherwise light = on ELSE
light [:=] 1;
END_IF;