Type Conversion Functions

Overview

It is not allowed to convert implicitly from a larger type to a smaller type (for example, from INT to BYTE or from DINT to WORD). To achieve this, you have to perform special type conversions. You can basically convert from any elementary type to any other elementary type.

Syntax

Typed conversion: <elem.type1>_TO_<elem.type2>

Overloaded conversion: TO_<elem.type2>

NOTE: At ...TO_STRING conversions the string is generated as left-justified. If it is defined too short, it will be cut from the right side.

The following type conversions are supported:

oBOOL_TO conversions

oTO_BOOL conversions

oconversion between integral number types

oREAL_TO-/ LREAL_TO conversions

oTIME_TO/TIME_OF_DAY conversions

oDATE_TO/DT_TO conversions

oSTRING_TO conversions

oTRUNC (conversion to DINT)

oTRUNC_INT

oANY_NUM_TO_<numeric data type>