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 |
---|---|
TRUE |
|
FALSE |
|
TRUE |
|
TRUE |