Operator ‘TO_BOOL’

This IEC operator is used for converting from another variable type into a BOOL variable.

<data type>_TO_BOOL

The result yields TRUE when the operand does not equal 0. The result yields FALSE when the operand equals 0.

For the STRING type, the result is TRUE if the operand is TRUE; otherwise it is FALSE.

Examples

ST Code Result
b := BYTE_TO_BOOL(2#11010101); TRUE
b := INT_TO_BOOL(0); FALSE
b := TIME_TO_BOOL(T#5ms); TRUE
b := STRING_TO_BOOL('TRUE'); TRUE
FBD Code Result
../_images/d6ca7678bc5cd791c0a8640e01117a32 TRUE
../_images/12b6dc87bc5ed559c0a8640e0084f08a FALSE
../_images/74a83842bc701bf0c0a8640e006ccb42 TRUE
../_images/04f2fe1abc6e9fe3c0a8640e016f4abc TRUE