REPLACE
Replaces a part of a message string by a new set of characters.

Arguments | |||
---|---|---|---|
IN | IN | MESSAGE | Any string |
Str | Str | MESSAGE | String to be inserted (to replace NbC chars) |
NbC | NbC | DINT | Number of characters to be deleted |
Pos | Pos | DINT | Position of the first modified character (first valid position is 1) |
REPLACE | Q | MESSAGE | Modified string: - NbC characters are deleted at position Pos - then substring Str is inserted at this position returns empty string if Pos <= 0 returns strings concatenation (IN+Str) if Pos is greater than the length of the IN string returns initial string IN if NbC <= 0 |
Example
(* FBD program using "REPLACE" function *)

(* ST Equivalence: *)
MyName := REPLACE ('Mr X JONES, 'Frank', 1, 4); (* MyName is 'Mr Frank JONES' *)
Provide Feedback