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

KEEP

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

3-62. KEEP COMMAND

3-63. Purpose.

The KEEP command saves the contents of the WORK file.

3-64. Form.

The form of the KEEP command is

    K[EEP][filename [(range)] [,UNN[UMBERED] ] ]



      or



    K[EEP] Q filename

For example,

   * KEEP KFILE (45/678),UNNUMBERED

3-65. Description.

If the filename parameter of the KEEP command refers to a new file, a file is opened under this name by MPE/3000, and the WORK file contents are stored on disc in this file. When range is specified in a KEEP command, only those lines in the WORK file specified by range are saved. (If a column number is specified in range, the entire line containing that column is saved.)

The file specified by filename must be in the log-on account.

In an interactive session, if an existing file is named in the KEEP command, EDIT/3000 asks if you wish to purge the old contents of the file. A positive response (YES or Y) causes the contents of the old file to be purged and the contents of the WORK file to be written into the kept file. Any other response terminates the KEEP operation.

If the KEEP command is used without any parameters, the filename is implied from the previous KEEP or TEXT command (whichever was performed last). If the UNNUMBERED option was specified in the previous KEEP or TEXT command, then this is also implied for the current KEEP command. EDIT/3000 produces an echo of the filename (and possibly the UNNUMBERED option) and copies the entire WORK file con- tents to that file.

The following example shows the KEEP command used without any parameters. In this case, both the filename and the UNNUMBERED option are implied:

   :EDITOR

   HP 32201A.7.01 EDIT/3000 WED, MAY 3, 19878, 1:33 PM

   (C) HEWLETT-PACKARD CO. 1976

   /TEXT KEPFIL,UNN

   /a

         4          MODIFICATIONS

         5          MORE: TO COME

         6          ...

   /K

    KEPFIL, UNN

   KEPFIL ALREADY EXISTS - RESPOND YES TO PURGE OLD AND THEN KEEP

   PUFGE OLD?Y

   /END



   END OF SUBSYSTEM

   :

Another example follows. This time only the filename is implied:

   :EDITOR

   HP32201A.7.01 EDIT/3000 WED, MAY 3, 1978, 1:43 PM

   (C) HEWLETT-PACKARD CO, 1976

   /TEXT KEPFIL

   /A

         7          several changes in addition

         8          MORE TO COME

         9          . . .

   /K

    KEPFIL

   KEPFTL ALREADY EXISTS - RESPOND YES TO PURGE OLD AND THEN KEEP

   PURGE OLD?Y

   /END

   END OF SUBSYSTEM

If the file in question belongs to a group and/or account other than that of the log-on account, the filename, group, and account are echoed.

In batch mode the contents of the old file are purged automatically when an existing old file is named in a KEEP command.

Records in the WORK file are saved as fixed-length records unless the SET VARIABLE option of the SET command is used, in which case the records are saved as variable-length records. (See paragraph 3-92 for a discussion of the SET command.)

An MPE/3000 error message is displayed if access to a file is not possible. See the MPE Commands Reference Manual for a discussion of file access.

Unless the UNNUMBERED parameter is specified in the KEEP command, the line numbers in the WORK file are placed in the kept file in ASCII format. The SET FRONT, SET REAR, and SET FORMAT commands determine where the line number information will be kept (front or rear of each record). See paragraph 3-92 for discussions of these commands. Line numbers in the WORK file are not copied to the kept file when the UNNUMBERED parameter of the KEEP command is declared.

Note that the default KEEP file is limited to disc files on the local computer. If a device or remote file is being used, an MPE file equation must have been issued and an asterisk ( * ) must be used to back-reference the file. (See the example of keeping to a card punch device in paragraph 3-67.)

The KEEPQ filename command saves the WORK file in its "edit" format, instead of in the format in which files normally are stored by the MPE/3000 file system. This is accomplished by appending EDIT/3000 variables to the file and assigning a filecode of 1050 or 1051 to the file. A filecode of 1050 signifies an EDIT/3000 KEEPQ file (non-COBOL) and a filecode of 1051 signifies an EDIT/300OKEEPQ file (COBOL). All such files are intended to be read only by EDIT/3000 although KEEPQ files can also be read by SPL/3000. To add the lockword to the new file would require EDIT/3000 to save it internally and thus cause a possible security violation.

3-66. Limitations.

The range and UNNUMBERED parameters of the KEEP command may be used only with the KEEP filename (or K filename) variation of the KEEP command. These parameters may not be used with the KEEPQ filename (or KQ filename) variation of the command.

Note that the KEEP command does not put a lockword on the file unless you explicitly specify one. For example, suppose you have a file named MYFILE with the lockword LOCKED. Issuing the command KEEP MYFILE/LOCKED will purge the old file and put the lockword LOCKED on the new file. However, if you issue the command KEEP MYFILE or if you issue the command K[EEP] with no parameters, you will be prompted for the lockword and EDIT/3000 will purge the old file (if you have supplied the correct lockword) and create a new file named MYFILE without a lockword.

A TEXT command (see paragraph 3-98) to copy the contents of an EDIT/3000 KEEPQ file into the WORK file renames that file with an EDIT/3000 Knnn name. To prevent destruction of such a file, enter the commands TEXT filename and KEEP filename in succession.

If SET FIXED is in effect, the KEEP file will have

  • record size = SET LENGTH if the file is unnumbered

  • record size = SET LENGTH + 6 bytes if the file is numbered in the COBOL format

  • record size = SET LENGTH + 8 bytes if the file is numbered in the default format

The blocking factor is calculated to allow the optimal trade-off between disc space used and time required for input-output.

If SET VARIABLE is in effect, the KEEP file will have

  • record size = 1276 bytes

  • blocking factor = 1

Using this large record size maximizes the disc space used by allowing many variable-length records to be entered in a single block.

Any of these attributes can be overridden by back-referencing a file equation for the KEEP file in the KEEP command.

NOTE: If a file equation is used to decrease the record size for a variable-length file, it may be necessary also to include the DISC parameter to increase the file limit. The default limit allows only as many blocks as are necessary to store all records when the block size is 1276 bytes.

Trying to KEEP a numbered file which is greater than 256 bytes wide (including 8 bytes for sequence numbers) will result in error #75, RECORDS TOO WIDE - KEEP UNNUMBERED.

3-67. Examples.

Several variations of the KEEP command are shown in the following examples.

  • KEEP filename

The first example uses the KEEP EDIT2 command to keep the file EDIT2. Because EDIT2 is an existing file, EDIT/3000 asks if it is OK to purge the old file.

   HP 32201A.4.01 EDIT/3000 WED, MAY 14, 1975, 3:43 PM

   /T EDIT2;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

            6  CHARACTERS, STRINGS OF CHARACTERS, OR ENTIRE

            9  LINES OF CHARACTERS CAN BE INSERTED, DELETED,

           10  REPLACED, MODIFIED, SEARCHED FOR, AND OTHERWISE

           11  MANIFUPLATED BY USING EDIT/3000 COMMANDS.

   /KEEP EDIT2

   EDIT2 ALREADY EXISTS - RESPOND YES TO PURGE OLD AND THEN KEEP

   PURGE OLD?Y
  • KEEP filename (range)

The KEEP range form, as in the following example, keeps only those lines specified in range (lines 8 through 11 in the example).

NOTE: SET SHORT was used in the next three examples.
   /KEEP TEST (8/11)

   /TEXT TEST

   CLEAR? Y

   /LIST ALL

            8  CHARACTERS, STRING 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.
  • KEEP filename, UNNUMBERED

When the KEEP filename, UNNUMBERED form of the KEEP command is used, as in the following example, the file can be copied back into the work file either with a TEXT filename, UNNUMBERED or a TEXT filename command.

Note that EDIT/3000 assigns line numbers to the unnumbered file TEST (as shown by the LIST ALL command).

   /KEEP TEST, UNNUMBERED

   PURGE OLD?Y

   /TEXT TEST, UNNUMBERED

   /LIST ALL

       1  CHARACTERS, STRING OF CHARACTERS, OR ENTIRE

       2  LINES OF CHARACTERS CAN BE INSERTED, DELETED,

       3  REPLACED. MODIFIED, SEARCHED FOR, AND OTHERWISE

       4  MANIPULATED BY USING  EDIT/3000 COMMANDS.
  • SEQUENCING INFORMATION

When the KEEP filename form of the KEEP command is used, EDIT/3000 appends eight bytes to the end of each record for sequencing information. When the TEXT file is copied back into the WORK file with a TEXT filename command, these eight bytes are deleted by EDIT/3000; however, if you do not wish the information contained in the eight bytes to be saved in the TEXT file, use the KEEP filename, UNNUMBERED form of the KEEP command.

In the next example, the SET RIGHT and SET LENGTH options are set to 52, then lines 1 through 10 of the WORK file are saved under the filename TEST. Once EDIT/3000 operation is terminated, the MPE/3000 command:LISTF TEST,1 shows that the length has been increased by eight bytes to 60 bytes.

   :EDITOR



   HP 32201A.4.01 EDIT/3000 TUE, JUN  3, 1975, 3:13 PM

   /S SHORT;T EDIT3;L 1/10

            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

            6  CHARACTERS, STRINGS OF CHARACTERS, OR ENTIRE

            9  LINES OF CHARACTERS CAN BE INSERTED, DELETED,

           10  REPLACED, MODIFIED, SEARCHED FOR, AND OTHERWISE

   /S RIGHT=52, LENGTH=52

   /K TEST(1/10)

   PURGE OLD?Y

   /E



      END OF SUBSYSTEM

   :LISTF TEST,1

   ACCOUNT=   GOODWIN    GROUP=     PUB



   FILENAME   CODE  ------------LOGICAL RECORD----------

                     SIZE TYPE         EOF     LIMIT



   TEST               60B  FA           10        10

                       ^

                       |

                     length
  • KEEPQ filename

The next example demonstrates the use of the KEEPQ command. In the first part of the example, the TEXT file EDIT2 is copied into the WORK file and listed. The VERIFY FILES command shows a WORK file of K18111336 and the MPE/3000 LISTF command displays the file parameters.

In the second part of the example, the same file is copied into the WORK file and listed. Then the KEEPQ command is entered. Note that now when the VERIFY FILES is entered, there is no entry for the WORK file and an attempt to LIST ALL results in the error message

    UNDEFINED TEXT

The MPE/3000 LISTF command shows that EDIT2 now has a filecode of 1050 (an EDIT/3000 KEEPQ file). Such a file can be read only by EDIT/3000 and can be used for no other purpose (no other EDIT/3000 commands will execute for such a file. For example, the LIST ALL command would not execute.)

The last part of the example shows how to use such a file, by entering the TEXT filename and KEEP filename commands in succession. Now the LIST ALL command executes.

: EDITOR



HP 32201A.4.01 EDIT/3000 MON, JUN 30, 19975, 1:36 PM

/SET SHORT;TEXT EDIT 2; LIST ALL

  1   LINE  1 OF WORK FILE

  2   LINE  2 OF WORK FILE

  3   LINE  3 OF WORK FILE

  4   LINE  4 OF WORK FILE

  5   LINE  5 OF WORK FILE

/VERIFY FILES

FILES:

  WORK: K1811336

  KEEP:

  TEXT: EDIT2.PUB.GOOWIN           MON, JUN 30, 1975, 1:36 PM

  JOIN:

/END



 END OF SUBSYSTEM

:LISTF EDIT2,2

ACCOUNT-  GOODWIN      GROUP-  PUB



FILENAME CODE  -----------------LOGICAL RECORD----------     ----SPACE---- ACC

                 SIZE TYPE            EOF      LIMIT R/B     SECTORS #X MX



EDIT2             80B  FA               5          5  16         10   1  1  ?@%%



:EDITOR



HP 32201A.4.01 EDIT/3000 MON, JUN 30, 19975, 1:36 PM

/SET SHORT;TEXT EDIT 2; LIST ALL

  1   LINE  1 OF WORK FILE

  2   LINE  2 OF WORK FILE

  3   LINE  3 OF WORK FILE

  4   LINE  4 OF WORK FILE

  5   LINE  5 OF WORK FILE

/KEEPQ EDIT2

PURGE OLD?Y

/VERIFY FILES

FILES:

  WORK:

  KEEP:  EDIT                     MON, JUN 30, 19975, 1:36 PM

  TEXT:  EDIT2.PUB.GOODWIN        MON, JUN 30, 19975, 1:36 PM

  JOIN:

/LIST ALL

*40*UNDEFINED TEXT

/END



 END OF SUBSYSTEM

:LISTF EDIT2,2

ACCOUNT=    GOODWIN           GROUP-    PUB



FILENAME CODE    ---------------LOGICAL RECORD----------     ----SPACE---- ACC

                 SIZE TYPE            EOF      LIMIT R/B     SECTORS #X MX



EDIT2   1050     112B  FA              22       2000   9         70   1 16 ?@%%



:EDITOR



HP 32201A.4.01 EDIT/3000 MON, JUN 30, 19975, 1:41 PM

/SET SHORT;TEXT EDIT 2; LIST ALL

  1   LINE  1 OF WORK FILE

  2   LINE  2 OF WORK FILE

  3   LINE  3 OF WORK FILE

  4   LINE  4 OF WORK FILE

  5   LINE  5 OF WORK FILE

/VERIFY FILES

FILES:

  WORK:  K1811341

  KEEP:  EDIT2.PUB.GOODWIN        MON, JUN 30, 19975, 1:41 PM

  TEXT:  EDIT2.PUB.GOODWIN        MON, JUN 30, 19975, 1:41 PM

  JOIN:

/END



 END OF SUBSYSTEM

:

EDIT/3000 monitors whether you make changes to the TEXT file or not. Thus, when using the TEXT or END command, you are not burdened with "OK TO CLEAR?" message unless the file has been altered. The "VERIFY ALL" and "VERIFY FILES" commands indicate if the WORK file has been altered with the following message:

    WORK FILE HAS BEEN ALTERED

For example,

   :EDITOR

   HP 32201A.7.01 EDIT/3000   WED, MAY 3, 1978, 1:42 PM



   /TEXT KEPFIL, UNN

   /V FILES

   FILES:

     WORK: K1231342

     KEEP:

     TEXT: KEPFIL.PUB.SHELL          WED, MAY 3, 1978, 1:42 PM

     JOIN:

   /ADD

     6    ADDITIONS

     7    MORE ADDITIONS

     8    ...

   /V FILES







   FILES:

     WORK:  K1231342

            WORK FILE HAS BEEN ALTERED

     KEEP:

     TEXT: KEPFIL.PUB.SHELL            WED, MAY 3, 1978  1:42 PM

     JOIN:

   /KEEP KEPFIL,UNN

   KEPFIL ALREADY EXISTS - RESPOND YES TO PURGE OLD AND THEN KEEP

   PURGE OLD?Y

   /V FILES

   FILES:

     WORK:  K1231342

     KEEP:  KEPFIL.PUB.SHELL          WED, MAY 3, 1978   1;48 PM

     TEXT:  KEPFIL.PUB.SHELL          WED, MAY 3, 1978   1:42 PM

     JOIN:

   /END



   END OF SUBSYSTEM

   :
  • KEEPING THE WORK FILE CONTENTS ON A CARD PUNCH DEVICE

In the next example, a FORTRAN/3000 source program, which has been copied into the WORK file with a TEXT command, is sent to a card punch device. To prevent the line numbers from being punched on the cards, the KEEP filename, UNNUMBERED form of the KEEP command is used.

   : FILE OUT;DEV=PUNCH

   : EDITOR



   HP 32201A.4.01 EDIT/3000 MON, JUN 30, 1975,    2:45 PM

   /S SHORT;TEXT FTRAN33

   /LIST ALL

        1              PROGRAM INTRINSICS

        2       C

        3       C FOPEN, FREAD, AND FCLOSE EXAMPLE

        4       C

        5         100  FORMAT(T2,S)

        6              CHARACTER*72 BUFFER, FILENAME*16

        7              LOGICAL LBUFFER(36)

        8              INTEGER FILENUMBER,FOPEN,FREAD

        9              EQUIVALENCE (LBUFFER,BUFFER)

       10              FILENAME="MAILLIST"

       11       C

       12       C  THE NEXT STATEMENT CALLS THE FOPEN INTRINSIC

       13       C

       14              FILENUMBER-FORPEN(FILENAME,\1\,\%105\,O,O,O,O,O,O,\0.0\,

       15              #0,0,0,\%16000\,

       16              IF(.CC.)40,10,40

       17        10     DISPLAY "FILENUMBER = ",FILENUMBER

       18       C

       19       C  THE NEXT STATEMENT CALLS THE FREAD INTRINSIC

       20       C

       21        20    N=FREAD(/FILENUMBER\,LBUFFER,\36\)

       22              IF(.CC.)50,30, 60

       23        30    WRITE(6,100)BUFFER[1:19]

       24              GOTO 20

       25        40    DISPLAY "FOPEN FAILURE"

       26              STOP

       27        50    DISPLAY "FREAD ERROR"

       28              STOP

       29       C

       30       C  THE NEXT STATEMENT CALLS THE FCLOSE INTRINSIC

       31       C

       32        60   CALL FLCOSE(\FILENUMBER\,\1\.0\)

       33             IF(.CC.)70,80,70

       34        70   DISPLAY "FCLOSE FAILURE"

       35             STOP

       36        80   DISPLAY "FILE CLOSED SUCCESSFULLY"

       37             STOP

       38             END

   /KEEP *OUT,UNN
  • USER LABELS

If the file is kept with a name that already exists, the old file is purged, but the user labels are not lost. They are passed on to the new file.

Feedback to webmaster