if_then
    Use if_then to complete an action when specific conditions occur.
Operands
if bool_expression then
<statement>;
| Operand | Type | Format | Enter | 
| Bool_ expression | BOOL | Tag expression | BOOL tag or expression that evaluates to a BOOL value (BOOL expression) | 
Description
The syntax is described in the table.

To use 
elsif
 or else
, follow these guidelines.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
          elsif
s and the else
.To do something when all of the 
if
 or elsif
 conditions are false, add an
          else
 statement.The table summarizes different combinations of 
if
, then
, elsif
, and
          else
.| If | And | Use this construct | 
| Doing 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 | |
| Selecting 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 | 
Affects Math Status Flags
No
Major/Minor Faults
None.
Examples
Example 1
if…then
| If performing this | Enter this structured text | 
| ifrejects > 3 then | ifrejects > 3 then | 
| conveyor = off (0) | conveyor := 0; | 
| alarm = on (1) | alarm := 1; | 
| end_if; | 
Example 2
if_then_else
| If performiing this | Enter this structured text | 
| If conveyor direction contact = forward (1) then | ifconveyor_direction then | 
| light = off | light := 0; | 
| Otherwise light = on | else | 
| light [:=] 1; | |
| end_if; | 
The [:=] tells the controller to clear light whenever the controller does the following :
Enters the RUN mode.
Example 3
if…then…elsif
| If performing this | Enter this structured text | 
| If sugar low limit switch = low (on) and sugar high limit switch = not high (on) then | ifSugar.Low & Sugar.High then | 
| inlet valve = open (on) | Sugar.Inlet [:=] 1; | 
| Until sugar high limit switch = high (off ) | elsifnot(Sugar.High) then | 
| Sugar.Inlet := 0; | |
| end_if; | 
The [:=] tells the controller to clear Sugar.Inlet whenever the controller does the following :
Enters the RUN mode.
Example 4
if…then…elsif…else
| If performing this | Enter this structured text | 
| If tank temperature > 100 | iftank.temp > 200 then | 
| then pump = slow | pump.fast :=1; pump.slow :=0; pump.off :=0; | 
| If tank temperature > 200 | elsiftank.temp > 100 then | 
| then pump = fast | pump.fast :=0; pump.slow :=1; pump.off :=0; | 
| Otherwise pump = off | else | 
| pump.fast :=0; pump.slow :=0; pump.off :=1; | |
| end_if; | 
Provide Feedback