AND

Top  Previous  Next

The logical operator AND operates on expressions with the BOOL, SINT, INT and DINT data types. When operating on data types other than BOOL, the operation is bitwise.

When operating on BOOL, it has the following truth table:

 

 

  Input 1     Input 2       Output1

-----------------------------------------

     0               0                0

     0               1                0

     1               0                0

     1               1                1

-----------------------------------------

 

 

 

Example:

INCLUDE rtcu.inc
 
VAR
  a : BOOL;
  b : BOOL;
  ia : INT;
  ib : INT;
END_VAR;
 
PROGRAM test;
 
BEGIN
  ...
  // Mask off the lower 8 bits of ib
  ia := ib AND 16#00FF;
  ...
  IF a AND b THEN
    // This will be executed if both a and b are TRUE
     ...
  END_IF;
  ...
END;
 
END_PROGRAM;