Overview of Structured Text Programming 
 
  Rockwell Automation Publication MOTION-RM002H-EN-P-February 2018  643 
The table shows some examples. 
Use this format  Example   
For this situation  Use 
BOOLtag  If photoeye is a BOOL tag and your specification says: "If photoeye_1 is on 
then..." 
IF photoeye THEN... 
NOT BOOLtag  If photoeye is a BOOL tag and your specification says: "If photoeye is off 
then..." 
IF NOT photoeye THEN... 
expression1 & expression2  If photoeye is a BOOL tag, temp is a DINT tag, and your specification says: "If 
photoeye is on and temp is less than 100 then..." 
IF photoeye & (temp<100) THEN... 
expression1 OR expression2  If photoeye is a BOOL tag, temp is a DINT tag, and your specification says: "If 
photoeye is on or temp is less than 100 then...". 
IF photoeye OR (temp<100) THEN... 
expression1 XOR expression2  If photoeye1 and photoeye2 are BOOL tags and your specification says: "If: 
photoeye1 is on while photoeye2 is off or 
photoeye1 is off while photoeye2 is on 
then..." 
IF photoeye1 XOR photoeye2 THEN... 
BOOLtag := expression1 & 
expression2 
If photoeye1 and photoeye2 are BOOL tags, open is a BOOL tag, and your 
specification says: "If photoeye1 and photoeye2 are both on, set open to true" 
open := photoeye1 & photoeye2; 
See also 
Structured Text Components: Expressions on page 638
 
Bitwise operators manipulate the bits within a value based on two values. 
For  Use this operator  Optimal data type 
bitwise AND  &, AND  DINT 
bitwise OR  OR  DINT 
bitwise exclusive OR  XOR  DINT 
bitwise complement  NOT  DINT 
This is an example. 
Use this format  Example 
For this situation  You'd write 
value1 operator value2  If input1, input2, and result1 are DINT tags and your specification says: 
"Calculate the bitwise result of input1 and input2. Store the result in 
result1." 
result1 := input1 AND input2; 
See also 
Structured Text Components: Expressions on page 
638