IEC operator for conversions from type BOOL to any other type.
BOOL_TO_<data type>
The conversion results for number types and for string types depend on the state of the operand:
Operand State |
Result for Number Types |
Result for String Types |
---|---|---|
TRUE |
1 |
TRUE |
FALSE |
0 |
FALSE |
Examples in ST with conversion results:
Example |
Result |
---|---|
i:=BOOL_TO_INT(TRUE); |
1 |
str:=BOOL_TO_STRING(TRUE); |
'TRUE' |
t:=BOOL_TO_TIME(TRUE); |
T#1ms |
tof:=BOOL_TO_TOD(TRUE); |
TOD#00:00:00.001 |
dat:=BOOL_TO_DATE(FALSE); |
D#1970 |
dandt:=BOOL_TO_DT(TRUE); |
DT#1970-01-01-00:00:01 |
Examples in IL with conversion results:
Example |
Result |
---|---|
LD TRUE |
1 |
LD TRUE |
'TRUE' |
LD TRUE |
T#1ms |
LD TRUE |
TOD#00:00:00.001 |
LD FALSE |
D#1970-01-01 |
LD TRUE |
DT#1970-01-01-00:00:01 |
Examples in FBD with conversion results:
Example |
Result |
---|---|
![]()
|
1 |
![]()
|
'TRUE' |
![]()
|
T#1ms |
![]()
|
TOD#00:00:00.001 |
![]()
|
D#1970-01-01 |
![]()
|
DT#1970-01-01-00:00:01 |