Basically, in using IEC constants, the smallest possible data type will be used. An exception is REAL/LREAL constants where LREAL is always used. If another data type has to be used, use typed literals (typed constants) without the necessity of explicitly declaring the constants. For this purpose, the constant will be provided with a prefix which determines the type.
<Type>#<Literal>
<Type>
is the desired data type. Possible entries are:
BOOL
SINT
USINT
BYTE
INT
UINT
WORD
DINT
UDINT
DWORD
REAL
LREAL
Write the type in uppercase letters.
<Literal>
specifies the constant. The data entered has to fit within the data type specified in <Type>
.
Example
var1:=DINT#34;
If the constant cannot be converted to the target type without data loss, a message will be generated.
You can use typed literals wherever normal constants can be used.