Conversion instructions
130
Part II IEC Instructions
STRING_TO_WORD
STRING (hexadecimal format) to WORD
Thereby the attached string is first converted to a value of the data type STRING[32]. Finally this is
converted to a value of the data type WORD via a sub-program of approx. 270 steps that is also
used in the functions STRING_TO_INT, STRING_TO_WORD, STRING_TO_DINT and
STRING_TO_DWORD.
To add an enable input and enable output to the instruction, select [With EN/ENO] from the
"Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the
context menu or press <Ctrl>+<Shift>+<v> in the programming window.
Example with and without EN/ENO:
Permissible format:
'[Space][Hexadecimal numbers][Space]' e.g. ' afFE '
Permissible characters:
Space All characters except for "+“ (plus), "-" (minus) and all hexadecimal
numbers
Hexadecimal
numbers
Hexadecimal numbers in the ranges "0 - 9“, "A - F“ or "a - f“.
The analysis ends with the first non-hexadecimal number.
PLC types
Availability of STRING_TO_WORD (see page 1331)
Data type Comment
STRING input variable
WORD output variable
Description
This function converts a STRING in hexadecimal format to a value of the data type WORD.
Data types