Extended instructions
9.2 String and character
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
347
String conversion instructions
9.2.3.1
S_CONV, STRG_VAL, and VAL_STRG (Convert to/from character string and number)
instructions
You can convert number character strings to number values or number values to number
character strings with these instructions:
● S_CONV converts (number string to a number value) or (number value to a number
string)
● STRG_VAL converts a number string to a number value with format options
● VAL_STRG converts a number value to a number string with format options
S_CONV (convert character string)
Table 9- 18 String conversion instruction
<Type>_TO_<Type>(in);
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 in-
struction simpler, but less flexible than the STRG_VAL and
For LAD / FBD: Click the "???" and select the data type from the drop-down list.
For SCL: Select S_CONV from the Extended I
nstructions, and answer the prompts for the data types for the conversion.
STEP 7 then provides the appropriate conversion instruction.
Table 9- 19 Data types (string to value)
OUT OUT String, WString, Char, WChar, SInt, Int, DInt, USInt, UInt, UDInt,
Output number value
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.