Extended instructions
8.2 String and character
S7-1200 Programmable controller
312 System Manual, 03/2014, A5E02486680-AG
REPLACE (Replace characters in a character string) instruction
Table 8- 64 Replace substring instruction
in1:=_string_in_,
in2:=_string_in_,
L:=_int_in_,
p:=_int_in);
Replaces L characters in the string parameter IN1. Replacement
starts at string IN1 character position P (inclusive), with
replacement characters coming from the string parameter IN2.
Table 8- 65 Data types for the parameters
String of replacement characters
Number of characters to replace
Position of first character to be replaced
OUT OUT String Result string
If parameter L is equal to zero, then the string IN2 is inserted at position P of string IN1
without deleting any characters from string IN1.
If P is equal to one, then the first L characters of string IN1 are replaced with string IN2
characters.
Table 8- 66 ENO status
0 P is greater than length of IN1 IN2 is concatenated with IN1
immediately following the last IN1
character
P points within IN1, but fewer than L characters remain in IN1 IN2 replaces the end characters of IN1
Resulting string after replacement is larger than maximum length of
OUT string
Resulting string characters are copied
until the maximum length of OUT is
Maximum length of IN1 is 0
IN2 characters are copied to OUT
L is less than 0, or P is less than or equal to 0
Current length is set to 0
Current length of IN1 exceeds maximum length of IN1, current
length of IN2 exceeds maximum length of IN2, or current length of
OUT exceeds maximum length of OUT
Maximum length of IN1, IN2 or OUT does not fit within allocated
Maximum length of IN1 or IN2 is 255, or maximum length of OUT is