CHANGE
Purpose
Use the CHANGE subcommand to change a specified group of characters to another group of characters of the same or a different length. You can use the CHANGE subcommand to change more than one line at a time.
Operands
- / (diagonal)
- signifies any delimiting character that does not appear in the character string.
- string1
- is a group of characters to be changed (old data).
- string2
- is the group of characters that is to replace string1 (new data). If string2 is omitted, it is assumed to be a null string. The trailing delimiter may be necessary in certain circumstances. For example, if string2 has trailing blanks, use the trailing delimiter to indicate where the string ends.
- target
- defines the number of lines to
be changed. Lines are changed starting with the current line, up to but not including the target
line. If you specify an asterisk (*), lines are changed until the end of the file (or the end of the
range). If you omit target, only the current line is changed.
You can specify target as an absolute line number, a relative displacement from the current line, a line name, or a string expression. For more information on targets, see LOCATE and z/VM: XEDIT User's Guide.
- p
- is the number of occurrences of string1 to be changed in each line. If you specify *, string1 is changed every time it appears in a line. If you omit p, string1 is changed only once.
- q
- is the relative number of the first occurrence of string1 to be changed in each line. If you omit q, the change starts with the first occurrence of string1 in each line.
Usage Notes
- The first nonblank character following the CHANGE subcommand is considered to be the delimiter.
For example:
change .z/VM.CMS.changesz/VM to CMSTo change blanks to nulls when SET HEX ON is in effect:change ?x'40'?x'00'?* * - If string2 is longer than string1 and if SET
SPILL OFF is in effect (the default), characters that have been pushed beyond the truncation column
are truncated. If SET SPILL ON or SET SPILL WORD is in effect, characters that have been pushed
beyond the truncation column are inserted in the file as one or more new lines, starting with the
first character or word that would have gone beyond the truncation column. If a line is spilled, no
additional changes are made on that line.
If string2 is shorter than string1, characters are shifted left (from the truncation column), and the line is padded with blanks (up to the truncation column).
- If string1 is represented as a null string, string2 is inserted in the line, starting at the beginning of the zone, which may or may not be column 1.
- Using CHANGE with SET ARBCHAR ON:
The expression that was in parentheses is now enclosed by quotation marks.set arbchar on . change /(.)/'.'/
String2 is represented as a null string. As a result, the expression in parentheses (and the parentheses) is deleted.change /(.)//
deletes all characters after y, ending at zone 2 (not truncation column). Characters from zone 2 to the truncation column are shifted left and the line is padded with blanks (up to the truncation column).set arbchar on $ change /y$/y/For additional examples of using CHANGE with SET ARBCHAR, see Examples and SET ARBCHAR.
To use CHANGE with SET ETARBCH see Using Double-Byte Character Sets.
- Using SET CASE and CHANGE:
String1 should be typed exactly as it appears in the file to be changed (even with SET CASE MIXED IGNORE).
- Using SET STAY and CHANGE:
If you specify a change is to occur on multiple lines and the change occurs, the current line pointer:
- Is unchanged, if SET STAY ON is in effect
- Moves to the last line scanned, if SET STAY OFF is in effect (the default)
- Using SET ZONE and CHANGE: The search for string1 occurs only between the left and right zones. However, characters are shifted left or the line is padded with blanks from the right zone up to the truncation column, as explained in Usage Note 2.
set arbchar on $ change /$/xy/This replaces all characters from zone 1 through zone 2 (not the truncation column) with characters xy. Characters from zone 2 to the truncation column are shifted left and the line is padded with blanks (up to the truncation column).
- Using CHANGE with SET SPAN ON:
The search for string1 is not affected by any of the settings you have using the SET SPAN subcommand to span several lines (the search is executed as if SET SPAN OFF were in effect).
- Using CHANGE with SET VARBLANK ON:
The search for string1 is not affected by any of the settings you have using SET VARBLANK to control the number of blank characters between two words in a target search (the search is executed as if SET VARBLANK OFF were in effect).
- The CHANGE subcommand updates the LASTLORC buffer. See SET CURLINE.
Examples
This section shows examples of the CHANGE subcommand. For more information, see z/VM: XEDIT User's Guide.
Example 1: In this example, CHANGE is used to change the first occurrence in the current line.
Current Line:
===== A rose is a rose is a rose.
change/rose/daisy/
===== A daisy is a rose is a rose.
Example 2: In this example, CHANGE is used to change all occurrences in the current line.
===== A daisy is a rose is a rose.
change/rose/daisy/ 1 *
===== A daisy is a daisy is a daisy.
Example 3: In this example, CHANGE is used to change every occurrence of daisy
to
rose
in every line of the file, beginning with the current line.
change/daisy/rose/ * *
Example 4: In this example, CHANGE is used to insert characters in column 1.
Current Line:
===== James Bernard is my favorite artist.
change//Mr. / (insert "Mr. " in
column 1) ===== Mr. James Bernard is my favorite artist.Example 5: In these examples, CHANGE is being used with SET ARBCHAR ON.
===== Lewis Carroll wrote 'The Walrus and the Carpenter.'
change/'$'/"$"/
(change single quotation marks to double quotation marks)
===== Lewis Carroll wrote "The Walrus and the Carpenter."
===== Robert Browning wrote (among other things) "My Last Duchess."
change / ($)// (string2
is a null string) ===== Robert Browning wrote "My Last Duchess."Responses
On a typewriter terminal, when verification is on, every line that is changed is displayed.
518E nn occurrence(s) changed on nn line(s);
nn line(s) {truncated|spilled} [RC=3]
517I nn occurrence(s) changed on nn line(s)Messages and Return Codes
- 503E
- {Truncated|Spilled} [RC=3]
- 511E
- String2 contains more arbitrary characters than string1 [RC=5]
- 520E
- Invalid operand: operand [RC=5]
- 543E
- Invalid number: number [RC=5]
- 545E
- Missing operand(s) [RC=5]
- 546E
- Target not found [RC=2]
- 585E
- No line(s) changed [RC=4]
where return codes are:
- 0
- Normal
- 1
- TOF or EOF reached during change
- 2
- Target line not found
- 3
- Truncation or spill occurred during the change
- 4
- No change occurred (string1 has not been found)
- 5
- Invalid or missing operand(s) or number
- 6
- Subcommand rejected in the profile due to LOAD error, or QUIT subcommand has been issued in a macro called from the last file in the ring
