HPlogo EDIT/3000 Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 3 EDIT/3000 COMMANDS

CHANGE

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

3-14. CHANGE COMMAND

3-15. Purpose.

The CHANGE command is used to alter specific portions of the WORK file contents.

3-16. Form.

The form of the CHANGE command is

   C[HANGE][Q] {oldstring

                startcolumn[/stopcolumn]} {TO

 , } {newstring}  [{IN

                                               , } [rangelist] ]

For example,

   CHANGEQ "SPL/3000" TO "FORTRAN/3000" IN 1/10

               ^                 ^          ^

               |                 |          |

            oldstring       newstring   rangelist

The example will change all occurrences of SPL/3000 to FORTRAN/3000 in lines 1 through 10. The use of Q suppresses the listing of all changed lines.

3-17. Description.

The CHANGE command searches through the range of positions specified in rangelist, locating each occurrence of oldstring or startcolumn. When each occurrence of the target (either oldstring or startcolumn) is located, newstring is substituted for oldstring, or newstring is substituted for the value contained in the startcolumn/stopcolumn area, or newstring is inserted before startcolumn (if stopcolumn was not specified in the command).

3-18. Limitations.

Description. The CHANGE command operates within the LEFT-RIGHT margins (see the SET command, paragraph 3-92); however, if newstring is longer than the oldstring it replaces, the CHANGE command can produce lines that exceed LENGTH by as much as 50 percent.

If the CHANGE oldstring TO newstring form of the CHANGE command is used and rangelist is omitted, the command will not execute unless oldstring is located first with a FIND oldstring command.

For example, the first line below contains the string "EDIT/3000". The commands FIND FIRST;CHANGE "EDIT/3000" TO "EDITOR/3000";LIST FIRST demonstrate that the command CHANGE "EDIT/3000" TO "EDITOR/3000" did not execute.

          1      1-2. WHAT IS EDIT?





          1       1-2. WHAT IS EDIT/3000?

          2

          3       EDIT/3000 IS A SUBSYSTEM OF THE HP 3000

          4       MULTIPROGRAMMING EXECUTIVE OPERATING SYSTEM

   / FIND FIRST;CHANGE "EDIT/3000" TO "EDITOR/3000;LIST FIRST

        1     1-2. WHAT IS EDIT/3000?

              ^(1 )

   *21*STRING NOT FOUND BEFORE LIMIT

       1      1-2.  WHAT IS EDIT/3000?

The rangelist parameter can be omitted, however, if the FIND string command is used first, where string is the string to be changed. See below.

   /FINDQ FIRST;FIND "EDIT/3000";CHANGE "EDIT/3000" TO "EDITOR/3000"

       1     1-2.   WHAT IS EDIT/3000?

                       (15 )^

       1     1-2.   WHAT IS EDITOR/3000?

If the startcolumn/stopcolumn parameters are included in the CHANGE command (following a FIND command to locate the line containing the string to be changed), the CHANGE command also will execute, even if the rangelist parameter is omitted, as shown by the sequence

     FIND 3;CHANGE 1/9 TO "EDITOR/3000";LIST 3
   /FIND 3;CHANGE 1/9 TO "EDITOR 3000";LIST 3

       3     EDIT/3000 IS A SUBSYSTEM OF THE HP 3000

             ^ (1 )

       3     EDITOR 3000 IS A SUBSYSTEM OF THE HP 3000

       3     EDITOR 3000 IS A SUBSYSTEM OF THE HP 3000
NOTE: To avoid a time-consuming search of all lines in the WORK file (unless, of course, this is desired) when an oldstring, newstring type of change is invoked, use specific line numbers in rangelist. In addition, if it is known that items to be changed are contained within specific columns (or to limit the columns for the CHANGE command execution), use the SET LEFT and SET RIGHT commands (see paragraph 3-92).

3-19. Examples.

The following examples show several variations of the CHANGE command. The location of the pointer is illustrated at the conclusion of each CHANGE command.

  • CHANGE oldstring TO newstring IN rangelist

In the following example, the characters ID (oldstring) are changed to EGO (newstring). Note that every occurrence of the characters ID was changed. To change only the word ID, the newstring parameter should be entered as "bIDb"

NOTE: Where necessary for clarity, blank spaces signified by the letter b in this manual.

After another change to change EGO back to ID, a new CHANGE command is entered to obtain the desired result.

The pointer is located one position beyond the last character of newstring at the conclusion of the CHANGE command.

   /LIST ALL

       1     THE FOLLOWING LINES WILL BE EDITED

       2     USING THE CHANGE COMMAND.

       3

       4     IT HAS BEEN SAID THAT THE ID MAY

       5     BE IDENTIFIED AS PART OF THE PSYCHE.



   /CHANGE "ID" TO "EGO" 4/5

       4     IT HAS BEEN SAEGO THAT THE EGO MAY

       5     BE EGOENTIFIED AS PART OF THE PSYCHE.

   /FIND*

       5     BE EGOENTIFIED AS PART OF THE PSYCHE.

              (7 )^

   /CHANGE "EGO" TO "ID" IN 4/5

      4      IT HAS BEEN SAID THAT THE ID MAY

      5      BE IDENTIFIED AS PART OF THE PSYCHE.

   /FIND*

      5      BE IDENTIFIED AS PART OF THE PSYCHE.

             (6 )^

   /CHANGE " ID " EGO " IN 4

      4      IT HAS BEEN SAID THAT THE EGO MAY

   /FIND*

      4      IT HAS BEEN SAID THAT THE EGO MAY

                                     (31 )^
  • CHANGE startcolumn TO newstring IN rangelist

The following CHANGE command example is used to insert the characters FOR EXAMPLE, BY before column 1 in line 2. Note that at the conclusion of the CHANGE command, the pointer is set immediately after the characters that were changed.

   /LIST 2

       2    USING THE CHANGE COMMAND.

   /CHANGE 1 TO "FOR EXAMPLE, BY " IN 2

       2    FOR EXAMPLE, BY USING THE CHANGE COMMAND.

   /FIND*

       2    FOR EXAMPLE, BY USING THE CHANGE COMMAND.

                         (17 )^
  • CHANGE oldstring,newstring,rangelist

The next example illustrates the use of commas instead of the words TO and IN in the CHANGE command.

   /List 4

       4     IT HAS BEEN SAID THAT THE EGO MAY

   /CHANGE "EGO "," ID ",4

       4     IT HAS BEEN SAID THAT THE ID MAY

   /FIND*

       4     IT HAS BEEN SAID THAT THE ID MAY

                                     (30 )^

If the CHANGE startcolumn/stopcolumn TO newstring form of the CHANGE command is used and newstring contains a different number of characters than that specified in startcolumn/stopcolumn, EDIT/3000 will contract or extend the line to accommodate the characters specified in newstring. See below.

   /F "EDIT/3000"

       3     EDIT/3000 IS A SUBSYSTEM OF THE HP 3000

             ^ (1  )

   /C 1/9    TO "EDITOR/3000"

       3     EDITOR/3000 IS SUBSYSTEM OF THE HP 3000

   /C 1/11 TO "EDITOR"

       3     EDITOR IS A SUBSYSTEM OF THE HP 3000
  • CHANGE oldstring TO newstring IN ALL

When ALL is specified in the rangelist parameter of the CHANGE command, EDIT/3000 searches through the entire WORK file for all occurrences of oldstring within the columns specified by SET LEFT and SET RIGHT and changes all such occurrences to newstring.

   /LIST ALL

       1     1-2.    WHAT IS EDIT/3000?

       2

       3     EDIT/3000 IS A SUBSYSTEM OF THE HP 3000

       4     MULTIPROGRAMMING EXECUTIVE OPERATING SYSTEM

       5     (MPE/3000) THAT IS USED CREATE AND

       6     MANIPULATE ASCII FILES.

       7

       8     CHARACTERS, STRINGS OF CHARACTERS, OR ENTIRE

       9     LINES OF CHARACTERS CAN BE INSERTED, DELETED,

      10     REPLACED MODIFIED, SEARCHED FOR, AND OTHERWISE

      11     MANIPULATED BY USING EDIT/3000 COMMANDS.

   /CHANGE "EDIT/3000 TO "HP 3000 TEXT EDITOR" IN ALL

       1     1-2.  WHAT IS HP 3000 TEXT EDITOR?

       3     HP 3000 TEXT EDITOR IS A SUBSYSTEM OF THE HP 3000

      11     MANIPULATED BY USING HP 3000 TEXT EDITOR COMMANDS.

   /FIND*

      11     MANIPULATED BY USING HP 3000 TEXT EDITOR COMMANDS.

                                                (41 )^
Feedback to webmaster