Change Command
Change Command
The CHANGE (C
) command is used in the Edit mode to replace a specific string or pattern within a dataset or member.
This command is particularly useful for editing large datasets where manual changes would be time-consuming.
Key Features -
- String Replacement: Replaces one string with another throughout a dataset or within a specified range.
- Flexible Search Criteria: Specify column ranges, case sensitivity, or labels to restrict the change scope.
- Global Changes: Replace multiple occurrences in one execution.
- Undo Support: Changes can be undone using the
UNDO
command ifSETUNDO
is enabled.
Syntax -
C 'old-string' 'new-string' [range] [column-range] [options]
Parameters -
Parameter | Description |
---|---|
old-string |
The string to be replaced. |
new-string |
The string to replace with. |
range |
Specifies the line range (e.g., .A .B for label range, or 5 10 for line numbers). |
column-range |
Restricts the change to specified columns (e.g., 10 20 ). |
options |
Additional flags like FIRST , ALL , PREFIX , SUFFIX , WORD , CHAR , etc., to refine the search. |
Common Options -
- FIRST: Changes only the first occurrence in each line.
- ALL: Changes all occurrences in the specified range.
- PREFIX: Matches strings that start with the specified string.
- SUFFIX: Matches strings that end with the specified string.
- WORD: Changes only complete words that match the
old-string
. - CHAR: Allows changes of substrings (default behavior).
Examples -
Scenario - Change "HELLO" in the program to "HI".
The changed line highlighted in red from first 1 to 6 columns and cursor will be placed after the first changed text.
More Examples -
Command | Function |
---|---|
C 'OLD' 'NEW' |
Replaces the first occurrence of OLD with NEW in each line of the dataset. |
C 'OLD' 'NEW' ALL |
Replaces all occurrences of OLD with NEW in the entire dataset. |
C 'DATA' 'INFO' 5 10 |
Replaces DATA with INFO between lines 5 and 10. |
C C'TEST' 'EXAM' |
Replaces TEST with RESULT within columns 1 to 20 in all lines. |
C 'ERROR' 'SUCCESS' .A .B |
Replaces ERROR with SUCCESS in the lines between labels .A and .B . |
C PREFIX'ABC' 'XYZ' |
Replaces strings starting with ABC with XYZ . |
C SUFFIX'END' 'FINISH' |
Replaces strings ending with END with FINISH . |
C P'.' X'00' |
Change all invalids to hex X'00'. |
C ALL 73 80 P'=' " " |
Blank out everything in cols 73-80. |
C ALL P'-' 1 10 "0" |
Change all non-numeric chars to '0' in cols 1-10 |
C ALL P'#' " " 20 25 |
Changes all numeric character between column 20 to 25 |