REPLACE (FUN)ΒΆ
FUNCTION REPLACE : STRING(255)
Replaces a specific number of characters of a string by another string
REPLACE(STR1, STR2, L, P)
means: Replace L
characters from STR1
by STR2
, beginning with the character in the P
position.
POS = 0
or POS = 1
, are both addressing the first character.
Note
The current implementation is unfortunately not correct for the case
P=0
. The implementation cannot be changed for compatibility reasons.If
P=0
is used, the parameter L
is internally reduced by one!It is generally recommended to use values in the range specified by IEC 61131-3. The smallest value for
P
is specified there as 1
.(* Example declaration *)
VarSTRING1 : STRING ;
(* Example in ST , result is 'SKYSI' *)
VarSTRING1 := REPLACE ('SUXYSI','K',2,2);
- InOut:
Scope
Name
Type
Comment
Return
REPLACE
STRING(255)
Resulting string
Input
STR1
STRING(255)
String of which a part is replaced
STR2
STRING(255)
String which replaces a part of
STR1
L
INT
Number of characters, counting from left
P
INT
Start position of the characters to be replaced.
P = 1
orP = 0
are both addressing the first character