Replacing Algorithm
For example, assuming three matched pairs of pseudo-text in a REPLACE statement:
- The comparison starts with the leftmost source program text word following the REPLACE statement, and with the first pseudo-text-1.
- Pseudo-text-1 is compared to an equivalent number of contiguous source
program text words according to the following rules:
- The comparison is character for character
- Uppercase and lowercase characters are equivalent (except within literals)
- Each occurrence of a separator comma, semicolon, and sequence of one or more spaces is treated as a single space
- Comment lines and blank lines are ignored for purposes of matching.
- IBM ExtensionIBM Extension Lines containing EJECT, SKIP 1/2/3, or TITLE statements are ignored for purposes of matching (they are treated as comment lines) End of IBM ExtensionEnd of IBM Extension
- Debugging lines are processed for matches, but the D in the indicator area is ignored
- If no match occurs, the comparison is repeated with each successive occurrence of pseudo-text-1 (in our example, there are three occurrences), until a match is found (go to Step 5)
- If no match is found after all, the next source program text word is treated as the leftmost program text word, and the cycle begins again at Step 1
- When a match is found, the corresponding pseudo-text-2 replaces the matched text in the source program
- The source program text word immediately following the rightmost text word that participated in the match becomes the leftmost source program text word. The cycle starts again (Step 1) with the first occurrence of pseudo-text-1.