Extended instructions
8.2 String and character
Table 8- 34
Examples of VAL_STRG conversion
Data type
IN value
UInt
123
UInt
0
UDInt
12345678
UDInt
12345678
Int
123
Int
-123
Real
-0.00123
Real
-0.00123
Real
-INF
Real
+INF
Real
NaN
UDInt
12345678
8.2.3.2
Strg_TO_Chars and Chars_TO_Strg (Convert to/from character string and array of
CHAR) instructions
Strg_TO_Chars copies an ASCII character string into an array of character bytes.
Chars_TO_Strg copies an array of ASCII character bytes into a character string.
Note
Only the zero based array types (Array [0..n] of Char) or (Array [0..n] of Byte) are allowed as
the input parameter Chars for the Chars_TO_Strg instruction, or as the IN_OUT parameter
Chars for the Strg_TO_Chars instruction.
Table 8- 35
Strg_TO_Chars instruction
LAD / FBD
302
P
SIZE
16
10
16
10
16
10
16
10
16
10
16
10
16
10
16
10
16
10
16
10
16
10
16
6
SCL
Strg_TO_Chars(
Strg:=_string_in_,
pChars:=_dint_in_,
Cnt=>_uint_out_,
Chars:=_variant_inout_);
FORMAT
PREC
(W#16#....)
0000
0
0000
2
0000
3
0001
3
0004
0
0004
0
0004
4
0006
4
N/A
4
N/A
4
N/A
4
N/A
3
Description
The complete input string Strg is copied to an array of
characters at IN_OUT parameter Chars.
The operation overwrites bytes starting at array element
number specified by the pChars parameter.
Strings of all supported max lengths (1..254) may be used.
An end delimiter is not written; this is your responsibility.
To set an end delimiter just after the last written array
character, use the next array element number
[pChars+Cnt].
OUT string
Current Temp =
xxxxxxx123 C
Current Temp =
xxxxxx0.00 C
Current Temp =
x12345.678 C
Current Temp =
x12345,678 C
Current Temp =
xxxxxx+123 C
Current Temp =
xxxxxx-123 C
Current Temp = xxx-
0.0012 C
Current Temp = -
1.2300E-3 C
Current Temp =
xxxxxx-INF C
Current Temp =
xxxxxx+INF C
Current Temp =
xxxxxxxNaN C
Current Temp =
xxxxxxxxxx C
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG
ENO
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
FALSE
FALSE
FALSE
FALSE