101BExtended instructions
8.2 String and character
S7-1200 Programmable controller
250
System Manual, 11/2011, A5E02486680-05
Table 8- 37 Chars_TO_Strg instruction
LAD / FBD
SCL
Description
Chars_TO_Strg(
Chars:=_variant_in_,
pChars:=_dint_in_,
Cnt:=_uint_in_,
Strg=>_string_out_);
All or part of an array of characters is copied to a string.
The output string must be declared before Chars_TO_Strg is
executed. The string is then overwritten by the Chars_TO_Strg
operation.
Strings of all supported maximum lengths (1..254) may be used.
The string maximum length value is not changed by
Chars_TO_Strg operation. Copying from array to string stops
when the maximum string length is reached.
A nul character '$00' or 16#00 value in the character array works
as a delimiter and ends copying of characters into the string.
Table 8- 38 Data types for the parameters (Chars_TO_Strg)
Parameter and type
Data type
Description
Chars
IN
Variant
The Chars parameter is a pointer to zero based array [0..n] of
characters to be converted into a 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
element values in DB1.
pChars
IN
Dint
Element number for the first character in the array to copy.
Array element [0] is the default value.
Cnt
IN
UInt
Count of characters to copy: 0 means all
Strg
OUT
String
Target string
Table 8- 39 Strg_TO_Chars instruction
LAD / FBD
SCL
Description
Strg_TO_Chars(
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 [Cnt].
Table 8- 40 Data types for the parameters (Strg_TO_Chars)
Parameter and type
Data type
Description
Strg
IN
String
Source string
pChars
IN
DInt
Array element number for the first string character written to
the target array