TO_BOOL Conversions

Conversion from another variable type to BOOL:

The result is TRUE when the operand is not equal to 0. The result is FALSE when the operand is equal to 0.

The result is true for STRING type variables when the operand is “TRUE”, otherwise the result is FALSE.

Examples in IL:

(*Result is TRUE *)
LD 213
BYTE_TO_BOOL
ST b

(*Result is FALSE *)
LD 0
INT_TO_BOOL
ST b

(*Result is TRUE *)
LD T#5ms
TIME_TO_BOOL
ST b

(*Result is TRUE *)
LD 'TRUE'
STRING_TO_BOOL
ST b

Examples in ST:

(* Result is TRUE *)
b := BYTE_TO_BOOL(2#11010101);

(* Result is FALSE *)
b := INT_TO_BOOL(0);

(* Result is TRUE *)
b := TIME_TO_BOOL(T#5ms);

(* Result is TRUE *)
b := STRING_TO_BOOL('TRUE');

Examples in FBD:

../_images/f1d538f06a08da9e0a317d3167a22238 Result is TRUE
../_images/c07bdf5e6a08fb380a317d3178a00f4c Result is FALSE
../_images/ebd4a9346a091b260a317d3154ca8676 Result is TRUE
../_images/343f15fe69c76bb20a317d316db299b6 Result is TRUE