REPLACE

The function REPLACE replaces a partial string from a larger string with a third string.
REPLACE (STR1, STR2, L, P) means: Replace L characters from STR1 with STR2 beginning with the character in the P position.
FUNCTION REPLACE: STRING (255)
VAR_INPUT
STR1 : STRING(255);
STR2 : STRING(255);
L : INT;
P : INT;
END_VAR
Example in IL:
LD 'SUXYSI'
REPLACE 'K',2,2
ST Var1 (* Result is 'SKYSI' *)
Example in ST:
Var1 := REPLACE('SUXYSI','K',2,2);
Requirements
Development environment | Target platform | PLC library to include |
---|---|---|
TwinCAT v3.0.0 | PC or CX (x86) | Tc2_Standard |