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.
Bemerkung
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
REPLACESTRING(255)Resulting string
Input
STR1STRING(255)String of which a part is replaced
STR2STRING(255)String which replaces a part of
STR1LINTNumber of characters, counting from left
PINTStart position of the characters to be replaced.
P = 1orP = 0are both addressing the first character