Change (Changing Strings)

Qedit 5.7 for HP-UX

Home Previous Next


Change (Changing Strings)

Replaces one string of characters by another string, the two strings being separated by a single quote character.

CHANGE "string1"string2" [ rangelist ]

(Q=no display, J=verify, T=CobX Tag)

(Default: rangelist = *)

The string1 tells Change what string of characters to find. The default for string1 is the last string used, and you specify this default via the null string (e.g., change ""xxx"). The null string recalls the last string and the window used with it. If the target string1 occurs more than once in a line, Qedit changes every occurrence.

The string2 tells Change what characters to substitute. In this format of the Change command, only three quote characters are used to define the two strings, not four as you would normally expect. Another oddity is that string2 does not become the current string. This is so that you can do another Change or Find command using "" as the target (i.e., the last string), finding and fixing multiple occurrences of the same string (e.g., find "nad"; CH ""and"; F; CH ""and"; ...). The third difference of string2 is that a null string for this parameter actually means "null". change "very"" 100 means remove "very" from line 100.

The rangelist tells Change what lines to search for string1. The default rangelist is the current line only.

If string2 is shorter than string1 (e.g., change "Robert"Bob"), Qedit shortens the line by shifting the rest of the line left. If string2 is longer (e.g., change "Bob"Robert"), Qedit lengthens the line by shifting characters right. If string2 is so much longer that the line would be too long, Qedit sends you into the Modify command to fix the line by hand.

Change prints each line that it updates, unless you use CQ.

Examples

/list 55                 {display line with mistake}
   55     select lines contaning both of two
/change "contan"contain" {change string in current line}
   55     select lines containing both of two
/change "sub"subindex" all    {make a global change}
   10     subindex = subindex + 1
   11     table(subindex) = 0
  213     if subindexway = 0  {oops-bad change!}
/cj "cust"Customer" 200/300   {change with user approval}
  225    Display Customer     {shown for approval}
Change okay (Y,N,or Modify) [No]: yes
/list 9           {display line to review}
    9     The test results were very exciting.
/c "very""        {remove word, change to null string}
    9     The test results were exciting.
/find "wiith"     {search forward for line with error}
   99    the string is combined wiith the second string
/c ""with"        {change "wiith" to "with"}
   99    the string is combined with the second string

Using Alternates to Quote

You may select your own quote character if you find " too much work because it is a shifted key. Among the alternatives are \ : and ' (apostrophe). See the "Glossary" for more on strings and other alternates to quotes.

/c :wiith:with:
/c \wiith\with\

Approving Each Changed Line

Use CJ to give yourself approval over each change before it is updated. With CJ, Qedit displays the line as it would be and asks you for a Yes, No, or Modify answer. Use CJ when you have trouble working out the precise strings to change.

Searching for Two Strings at Once

Because the rangelist can contain a search string, you can actually select lines containing both of two strings:

/c "xxx"filename" all          {"xxx" becomes "filename" in ALL}
/c "xxx"filename" "rename"     {line must contain "rename" too}

Including a Window

The form of Change command just described requires only three quotes per command, but does not allow all options. You cannot specify a special window - you will always use the default Set Window value. To do a Change with a special window, you must specify four quote characters, two for each string:

CHANGE "string1" (window) "string2" [ rangelist ]

Each string is delimited by two quote characters and the two strings must be separated by a space or a comma. Between the two strings you may insert a window such as (SMART) or (20/30) or (UPSHIFT).

Changing Within a Column Range

If you insert a column window, Qedit changes only the columns within the window. Columns outside the window are untouched:

/change "CUSTREC" (10/39) "CUSTOMER-RECORD"

In this example, "CUSTREC" is expanded to "CUSTOMER-RECORD", but the data at column 40 and beyond is not moved. In addition, the Change must not cause the rest of the window to overflow.

Changing Uppercase and Lowercase

If you specify an upshift window, Qedit ignores the case of letters when matching the target string. It will match words that are spelled with caps or without:

/change "JONES" (upshift) "Fitz-Jones" all

In this example, Change selects lines containing "JONES", "Jones", or even "joneS".

Avoiding Changes to Embedded Words

If you specify a Smart window, Qedit rejects those matches in which the target string is actually in the middle of another word:

/change "FRANK" (smart) "Frank" all

This example selects "FRANK", but reject "FRANKLYN." You can combine Smart and Upshift.

Patterns and Windows

In other commands the window can specify a pattern to match. In the Change command patterns are not allowed, because Change cannot perform pattern changes. However, a string specified in the rangelist portion of the Change command may be a pattern. For example:

/change "CUSTREC" "CUST-REC" "@01@PIC@" (pattern)
                 {change custrec to cust-rec in all lines that}
                 {   also contain "01" and "PIC" in that order}

CobX Tags

Cobol tags are short strings stored in columns 73 to 80 of CobX source files. The Cobol tag value is defined using the Set X command. Once enabled, updated lines and added lines are automatically updated with the tag. They can also be modified manually with custom tag values.

In its regular form, the Change command affects only the text area in columns 7 to 72. If you wish to make changes to Cobol tags, use the T suffix. You can think of it as the Tag option. This option operates only on the tag area itself, columns 73 to 80.

/change "CUST" "SUPP" all
                 {change cust to supp in all lines.   }
                 { cust must be between columns 7 and 72.  }
/changeT "CUST" "SUPP" all
                 {change cust to supp in all lines.        }
                 { cust must be between columns 73 and 80.  }

To to this, the Tag option temporarily changes the margins to (73/80). Qedit displays a warning every time this option is used. Because the margin values have changed, explicit column range in a Window can only be between 73 and 80.

/changeT "CUST" (50/60) "SUPP" all
Warning:  ChangeT: editing the Cobol tag area only (73-80).
Error: Window
/changeT "CUST" (73/80) "SUPP" all
Warning:  ChangeT: editing the Cobol tag area only (73-80).
   10      SUPP0102
1  line changed

Because the margins have been changed, Qedit displays text in the tag area only except when the Justify option is used. In this case, Qedit prompts for confirmation before making the change. It would be hard to determine if a line needs to be changed based only on the tag value. So, when the Justify option is used, Qedit displays the complete line. The user has the option to accept the changes, reject the changes or manually modify the line. If the user chooses to modify the line, only the tag is displayed.


Home Previous Next