IEC operator for conversions from another variable type to BOOL.
<data 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 ST with conversion results:
Example |
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 |
Examples in IL with conversion results:
Example |
Result |
---|---|
LD 213 |
TRUE |
LD 0 |
FALSE |
LD T#5ms |
TRUE |
LD 'TRUE' |
TRUE |
Examples in FBD with conversion results:
Example |
Result |
---|---|
![]()
|
TRUE |
![]()
|
FALSE |
![]()
|
TRUE |
![]()
|
TRUE |