REPLACE (replace sub-string)
The REPLACE instruction replaces parts of a string with new sets of characters.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the Micro810, L20E, L50E, and L70E controllers.
REPLACE

Parameter | Parameter Type | Data Type | Description |
---|---|---|---|
EN | Input | BOOL | Function enable.
Applies to ladder diagram programs. |
IN | Input | STRING | Any string. |
Str | Input | STRING | String to be inserted (to replace NbC chars). |
NbC | Input | DINT | Number of characters to be deleted. |
Pos | Input | DINT | Position of the first modified character (first valid position is 1). |
REPLACE | Output | STRING | Modified string. The NbC characters are deleted at position Pos, then the substring Str is inserted at this position. Can be:
|
ENO | Output | BOOL | Enable output. Applies to ladder diagram programs. |
REPLACE examples
REPLACE function block diagram example

REPLACE ladder diagram example

REPLACE structured text example

Results

Replacing a part of a string with a new set of characters.
(* ST Equivalence: *) MyName := REPLACE ('Mr X JONES, 'Frank', 1, 4); (* MyName is 'Mr Frank JONES' *)
Provide Feedback