BOOL_TO_<type>

This IEC operator converts from the data type BOOL to a different data type.

Syntax: BOOL_TO_<data type>

With numerical data types the result is 1 if the operand is TRUE and 0 if the operand is FALSE. With the data type STRING the result is TRUE or FALSE.

Samples:

ST code

Result

nVar := BOOL_TO_INT(TRUE);

1

sVar := BOOL_TO_STRING(TRUE);

'TRUE'

tVar := BOOL_TO_TIME(TRUE);

T#1ms

tVar := BOOL_TO_TOD(TRUE);

TOD#00:00:00.001

dVar := BOOL_TO_DATE(FALSE);

D#1970

dtVar := BOOL_TO_DT(TRUE);

DT#1970-01-01-00:00:01

FBD code

Result

BOOL_TO_<type> 1:

1

BOOL_TO_<type> 2:

'TRUE'

BOOL_TO_<type> 3:

T#1ms

BOOL_TO_<type> 4:

TOD#00:00:00.001

BOOL_TO_<type> 5:

D#1970-01-01

BOOL_TO_<type> 6:

DT#1970-01-01-00:00:01

See also: