REPLACE from Position
Syntax
![]()
Command
Mandatory parameter Optional parameter Mandatory keyword Optional keyword |
REPLACE (<Destination>, <Position>, <Source>)
Description
Replaces a part or all of the specified destination variable starting at the specified position with the contents of the source.
Diagram
Returned value type
None
Parameters
Parameter | Description |
<Destination> |
The variable to replace a part of. |
<Position> |
The one based position in the destination variable from where to start the replace. |
<Source> |
Expression giving an alpha value to move into the destination variable. |
Remarks
When an invalid starting position is specified (E.g. larger than the length of the destination variable), the system item RESOK will be set to False otherwise RESOK will be left unchanged.
When the length of the source is shorter than the space left in the destination variable counted from the start position the characters beyond will be left unchanged.
When the length of the source is longer than the space left in the destination variable counted from the start position the source will be truncated to match the space left.
When the source expression is a single copy function, then the length of the source will be the length specified in the copy function.
Example
areacode := '524'
extension := '515386'
telno := '---------------'
replace (telno, 1, countrycode)
replace (telno, 6, areacode)
replace (telno, 10, extension)
// telno is now 0031-524-515386