CHANGE

Read syntax diagramSkip visual syntax diagram Change1 / string1 //111/ string2/111/111target*11p*1q
Notes:
  • 1 If string1 or string2 is omitted, it is assumed to be a null string.

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

  1. The first nonblank character following the CHANGE subcommand is considered to be the delimiter.

    For example:

    change .z/VM.CMS. changes z/VM to CMS

    To change blanks to nulls when SET HEX ON is in effect:
    change ?x'40'?x'00'?* *
  2. 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).

  3. 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.
  4. Using CHANGE with SET ARBCHAR ON:
    set arbchar on .
    change /(.)/'.'/
    The expression that was in parentheses is now enclosed by quotation marks.
    change /(.)//
    String2 is represented as a null string. As a result, the expression in parentheses (and the parentheses) is deleted.
    set arbchar on $
    change /y$/y/
    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).

    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.

  5. 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).

  6. Using SET STAY and CHANGE:

    If you specify a change is to occur on multiple lines and the change occurs, the current line pointer:

    1. Is unchanged, if SET STAY ON is in effect
    2. Moves to the last line scanned, if SET STAY OFF is in effect (the default)
  7. 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).

  8. 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).

  9. 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).

  10. 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.

On a display terminal, when verification is off and a change is made, one of the following messages 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