Extended instructions
8.2 String and character
S_CONV (convert character string)
Table 8- 18
String conversion instruction
LAD / FBD
SCL
out :=
<Type>_TO_<Type>(in);
For LAD / FBD: Click the "???" and select the data type from the drop-down list.
1
For SCL: Select S_CONV from the Extended Instructions, and answer the prompts for the data types for the conversion.
2
STEP 7 then provides the appropriate conversion instruction.
Table 8- 19
Data types (string to value)
Parameter and type
IN
IN
OUT
OUT
Conversion of the string parameter IN starts at the first character and continues until the end
of the string, or until the first character is encountered that is not "0" through "9", "+", "-", or
".". The result value is provided at the location specified in parameter OUT. If the output
number value does not fit in the range of the OUT data type, then parameter OUT is set to 0
and ENO is set to FALSE. Otherwise, parameter OUT contains a valid result and ENO is set
to TRUE.
Input String format rules:
● If a decimal point is used in the IN string, you must use the "." character.
● Comma characters "," used as a thousands separator to the left of the decimal point are
allowed and ignored.
● Leading spaces are ignored.
S_CONV (value to string conversion)
Table 8- 20
Data types (value to string)
Parameter and type
IN
IN
OUT
OUT
294
Data type
String
String, Char, SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal
Data type
String, Char, SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal
String
Description
Converts a character string to the corresponding value, or a value
to the corresponding character string. The S_CONV instruction
has no output formatting options. This makes the S_CONV
instruction simpler, but less flexible than the STRG_VAL and
VAL_STRG instructions.
Description
Input character string
Output number value
Description
Input number value
Output character string
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG