REPLACE
ANSI
The REPLACE instruction (which may be abbreviated as REP) uses pairs of characters to specify which character to search for in the destination character string and what character to replace it with if found. The instruction uses the following format:
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
source
Required. A previously defined Character String Variable or Literal defining the character replacement pairs.
sep
Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.
dest
Required. A previously defined Character String Variable whose characters are replaced.
Flags Affected: EOS, ZERO
Note the following:
The {source} Logical String or literal must contain one or more pairs of characters in the format (XY). A case sensitive search is performed against the Logical String of {dest} for X. If found, the X is replaced with Y in {dest}. The {source} remains unchanged.
If a replacement occurs, the EQUAL (or ZERO) Condition Flag is set.
If the {source} Logical String or literal contains an odd number of characters, the EOS Condition Flag is set and no replacement occurs.
Enhanced ARRAY processing is supported for the REPLACE instruction.
See Also: Example Code, Character String Instructions
![]() |