Typecast BOOL(expression)

Top  Previous  Next

The BOOL typecast operator is used to convert an expression to a BOOL type. Only if the expression is equal to 0 will the result be FALSE. Otherwise it will be TRUE.

 

 

Example:

INCLUDE rtcu.inc
 
VAR
  a : INT;
  b : BOOL;
END_VAR;
 
PROGRAM test;
 
BEGIN
  // Convert 'a' which is a INT type to a BOOL (if a <> 0, b will be TRUE, else FALSE)
  b := BOOL(a);
  ...
END;
 
END_PROGRAM;