Extended instructions
9.2 String and character
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
357
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 allow
ed 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 9- 35 Strg_TO_Chars instruction
Strg:=_string_in_,
pChars:=_dint_in_,
Cnt=>_uint_out_,
Chars:=_variant_inout_);
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
Table 9- 36 Data types for the parameters (Strg_TO_Chars)
pChars IN DInt Array element number for the first string character written to
Chars IN_OUT Variant The Chars parameter is a pointer to a zero-based array
[0..n] of characters copied from the input string. The array
can be declared in a DB or as local variables in the block
interface.
Example: "DB1".MyArray points to MyArray [0..10] of Char
Count of characters copied