Conversion instructions
213
Part II IEC Instructions
LD
ST
When programming with structured text, enter the following:
result_string:=WORD_TO_STRING(input_value);
Example 2
This example illustrates how you create STRING[4] out of the data type WORD in which the
leading part of the string '16#' is cut out.
The example is programmed in LD and IL. The same POU header is used for both programming
languages.
POU header
In this example, both an input variable input_value of the data type WORD and an output variable
result_string of the data type STRING[4] are declared.
Body
In carrying out the operation in question, the standard function RIGHT is attached to the function
WORD_TO_STRING. RIGHT creates a right-justified character string of length L.
In the example, the output string of WORD_TO_STRING function is added at the input of the
RIGHT function. At the L input of RIGHT, the INT constant 4 determines the length of the STRING
to be replaced. Out of the variable input_value = 0001234, the result_string 1234 results from the
data type conversion and the RIGHT function.
LD