General Information
For general hints to be considered during type conversion, refer to the chapter Type Conversion Functions.
Definition
IEC operator for conversions from another variable type to BOOL.
Syntax
<data type>_TO_BOOL
Conversion Results
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
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
Examples in IL with conversion results:
Example
|
Result
|
LD 213
BYTE_TO_BOOL
ST b
|
TRUE
|
LD 0
INT_TO_BOOL
ST b
|
FALSE
|
LD T#5ms
TIME_TO_BOOL
ST b
|
TRUE
|
LD 'TRUE'
STRING_TO_BOOL
ST b
|
TRUE
|
Examples in FBD
Examples in FBD with conversion results:
Example
|
Result
|
|
TRUE
|
|
FALSE
|
|
TRUE
|
|
TRUE
|