Operator ‘TO_<xxx>

This IEC operator is used for converting variables of one data type into another data type, where the input type is not explicitly given (overflow conversion).

TO_<data type>

The function depends on what is described for each typed conversion.

Examples

ST implementation language:

VAR
   iVar : INT;
   bVar : BOOL;
   sVar : STRING;
   rVar : REAL;
END_VAR

wVar := TO_WORD('123');\ (* Result: 123 *)
bVar := TO_BOOL(1);\ \ \ \ \ (* Result: TRUE *)
sVar := TO_STRING(342);\ (* Result: '342' *)
iVar := TO_INT(4.22);\ \ \ (* Result:  4 *)