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

BEGIN

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

4-7. BEGIN-END COMMANDS

4-8. PURPOSE

The BEGIN-END commands are used to block a set of EDIT/3000 commands within a WHILE command block.

4-9. FORM

The form of the BEGIN-END commands is

        B[EGIN][Q]

        E[ND]

4-10. DESCRIPTION

A BEGIN-END pair can include any number of EDIT/3000 commands. These commands will execute repeatedly until the flag becomes false ,or until the SET TIME = limit option is reached.

For example,

        FINDQ FIRST

        WHILE

            FINDQ "PROGRAMMER"

            BEGIN

                CHANGE "PROGRAMMER" TO "PGMR" IN *

                LIST *

                END

will find all occurrences of "PROGRAMMER" in the WORK file, change this string to "PGMR" and list the line where the string was found. When the end of the WORK file is encountered, EDIT/3000 sets the flag to false and the iterations terminate.

If the BEGINQ form of the command is used, the soft error message (which occurs when the flag is set to false) will not be displayed.

4-11. LIMITATIONS

BEGIN-END pairs should be used only within a WHILE command block. The number of BEGIN-END pairs allowed in a single WHILE block is determined by the SET DEPTH = limit option in effect. The default limit is 10.

The commands between a BEGIN-END pair (within a WHILE block) will execute as long as the flag is true or until the SET TIME = limit value is not exceeded. The default limit is 50 iterations. If used outside a WHILE block, the commands between the BEGIN-END pair will execute only once.

4-12. EXAMPLES

The WORK file is shown below.

   /S SHORT;T EDIT3;L 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 TO 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.

      12

      13     1-2.  EDIT/3000 FEATURES

      14

      15     WITH EDIT/3000, IT IS POSSIBLE TO

      16

      17     CREATE AND BUILD A NEW FILE (CALLED A WORK FILE)

      18     BY ENTERING COMMANDS AND LINES OF TEXT FROM THE

      19     STANDARD INPUT DEVICE OR FROM A SPECIAL DISC FILE

      20     CALLED THE HOLD FILE.

      21

      22     SAVE THE WORK FILE INTO A PERMANENT FILE CALLED

      23     THE TEXT FILE.

      24

      25     CALL THE TEXT FILE BACK INTO THE WORK FILE FOR

      26     FURTHER ADDITIONS AND/OR EDITING.

      27

      28     CHANGE ALL OCCURENCES OF A CHARACTER STRING WITH

      29     ONE COMMAND.

      30

      31     DELETE CHARACTERS AND LINES FROM THE WORK FILE.

   

The following example shows a BEGIN-END pair nested within another BEGIN-END pair. Note that in a session EDIT/3000 indents after the WHILE command and after each BEGIN command.

The first BEGIN-END pair finds "SUBSYSTEM" and changes it to "SUB-SYSTEM." The second BEGIN-END pair "FEATURES", changes it to "CAPABILITIES", and lists the entire WORK file.

The next iteration of the command FIND "SUBSYSTEM" fails, the flag is set to false, causing the error message shown to be displayed, and the iterations terminate.

   /FINDQ FIRST

   /WHILE

   /   FIND "SUBSYSTEM"

   /   BEGIN

   /      CHANGE "SUBSYSTEM" TO "SUB-SYSTEM"

   /      BEGIN

   /         FIND "FEATURES"

   /         CHANGE "FEATURES" TO "CAPABILITIES"

   /         LIST ALL

   /         END

   /      END

         3   EDIT/3000 IS A SUBSYSTEM OF THE HP 3000

                            ^ (16 )

         3   EDIT/3000 IS A SUBSYSTEM OF THE HP 3000

        13   1-2.  EDIT/3000 FEATURES

                             ^ (17 )

        13   1-2.  EDIT/3000 CAPABILITIES

         1   1-2.  WHAT IS EDIT/3000

         2

         3   EDIT/3000 IS A SUB-SYSTEM OF THE HP 3000

         4   MULTI-PROGRAMMING EXECUTIVE OPERATING SYSTEM

         5   (MPE/3000) THAT IS USED TO 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.

        12

        13   1-2.  EDIT/3000 CAPABILITIES

        14

        15   WITH EDIT/3000, IT IS POSSIBLE TO

        16

        17   CREATE AND BUILD A NEW FILE (CALLED A WORK FILE)

        18   BY ENTERING COMMANDS AND LINES OF TEXT FROM THE

        19   STANDARD INPUT DEVICE OR FROM A SPECIAL DISC FILE

        20   CALLED THE HOLD FILE.

        21

        22   SAVE THE WORK FILE INTO A PERMANENT FILE CALLED

        23   THE TEXT FILE

        24

        25   CALL THE TEXT FILE BACK INTO THE WORK FILE FOR

        26   FURTHER ADDITIONS AND/OR EDITING.

        27

        28   CHANGE ALL OCCURENCES OF A CHARACTER STRING WITH

        29   ONE COMMAND.

        30

        31   DELETE CHARACTERS AND LINES FROM THE WORK FILE.

   *21*STRING NOT FOUND BEFORE LIMIT

   AT DEPTH 2

   

The next example finds the string "EDIT/3000" and changes it to "HP 3000 TEXT EDITOR". The second BEGIN-END pair finds "FEATURES" and changes it to "CAPABILITIES". So that EDIT/3000 can locate additional "EDIT/3000" strings (between the first "EDIT/3000" and "FEATURES"), the FINDQ FIRST command sets the pointer back to the first line in the WORK file.

EDIT/3000 then locates "EDIT/3000" in lines 3, 11, 13,and 15,and changes all occurrences to "HP 3000 TEXT EDITOR".

When the condition specified in the first FIND command fails, the iterations terminate and the error message is displayed.

   /FINDQ FIRST

   /WHILE

   /   FINDQ "EDIT/3000"

   /   BEGIN

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

   /      BEGIN

   /         FIND "FEATURES"

   /         CHANGE "FEATURES" TO "CAPABILITIES"

   /         FINDQ  FIRST

   /         END

   /      END

       1     1-2.   WHAT IS HP TEXT EDITOR?

      13     1-2.   EDIT/3000 FEATURES

                              ^ (17 )

      13     1-2.  EDIT/3000 CAPABILITIES

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

   *21*STRING NOT FOUND BEFORE LIMIT

   AT DEPTH 4

      11     MANIPULATED BY USING HP 3000 TEXT EDITOR COMMANDS.

   *21 *STRING NOT FOUND BEFORE LIMIT

   AT DEPTH 4

      13    1-2.  HP 3000 TEXT EDITOR CAPABILITIES

   *21*STRING NOT FOUND BEFORE LIMIT

   AT DEPTH 4

      15    WITH HP 3000 TEXT EDITOR. IT IS POSSIBLE TO

   *21*STRING NOT FOUND BEFORE LIMIT

   AT DEPTH 4

   *21*STRING NOT FOUND BEFORE LIMIT

   AT DEPTH 2

   
Feedback to webmaster