Conversion instructions
219
Part II IEC Instructions
Body
The INT_value of the data type INT is converted into STRING[8]. The converted value is written to
result_string. When the variable INT_value = -12345, result_string shows '
-12345'.
LD
ST
When programming with structured text, enter the following:
result_string:= INT_TO_STRING(input_value);
Example 2
This example illustrates how you create a STRING[2] that appears right justified out of the data
type INT.
POU header
In this example, both an input variable INT_value of the data type INT and an output variable
result_string of the data type STRING[2] are declared.
Body
In carrying out the operation in question, the standard function RIGHT (see page 265) is attached
to the function INT_TO_STRING. RIGHT creates a right-justified character string with the length L.
In the example, the variable INT_variable = 12 is converted by INT_TO_STRING to the dummy
string '
12'. The function RIGHT then creates the result_string '12'.
LD
ST
When programming with structured text, enter the following:
result_string:=RIGHT(IN:=INT_TO_STRING(input_value), L:=2);