Keep Command [K]

Qedit 5.7 for HP-UX

Home Previous Next


Keep Command [K]

Creates a standard disc file and writes the workfile into it. Keep is the reverse of Text, which copies a standard disc file into a workfile that you can edit. Use Text when you need to duplicate a file.

KEEP [filename][,options] [ rangelist ]

(Q=no linenums)

(Defaults: rangelist=ALL, filename=last)

Keep Options

Qedit allows several options on the Keep command. Note that the comma preceding the option name is mandatory, and that spaces are not allowed before the comma or the option name.

Keep filename,UNN unnumbered (same as KQ)
Keep filename,YES go ahead and purge old file
Keep filename,NO never purge an old file
Keep filename,XEQ assign xeq access
Keep filename,IFDIRTY only if changes made
Keep filename,LF insert Newline delimiters
Keep filename,NOLF Do not insert Newline delimiters

Keep creates a new disc file named filename. You can combine several options on the same Keep command. The default filename is the name of the last Text or full Keep (i.e., it does not count if you use a rangelist or have reduced the margins with Set Left or Set Right). If filename already exists, Qedit will ask you to verify that it is okay to purge it unless you specify the ,YES or ,NO option.

Sometimes the file will have sequence numbers in each line (this is called numbered), but you can omit the sequence numbers with KQ, or by specifying the ,UNN option.

Keep transfers rangelist lines from the workfile to filename. The default rangelist is ALL. Warning: Qedit writes only the data within the current left and right margins, so reset the margins first if you want the entire line (e.g., Set Left; Set Right).

Examples

/text /src/report.cob        {make a copy}
Scratch file
/find "FUNCTION-CODE"
   14       05  FUNCTION-CODE      PIC X8.
/change "X8"X10"
   14       05  FUNCTION-CODE      PIC X10.
/keep /src/new.cob           {create a new file}
    ...                      {do some more changes}
/keep                        {save again with same name...}
/src/new.cob # of records = 127
Purge existing file [No]? yes  {you must authorize purge!}
/s left 1;s right 50         {define margins as first 50 columns}
/kq /data/nov99              {unnumbered with 50-byte records}
/k notes,UNN,YES             {unnumbered, purge old file}
/keep ,yes                   {keep to last text, purging old}

Absolute File Name

When you are using CD, you may find yourself doing the following: Text file xxx, change to another directory to add from some other files, then Keep to update your original file. Keep defaults to the "absolute" name (e.g., /user/dev/lib/src/xxx). This means you can change to other directories after a Text, but still easily Keep the file back under its original name. In the past, Keep would default to the "relative" name of the Text file (e.g., xxx), saving the file in your current working directory.

Keep Only When Changes Were Made

Keep,Ifdirty only does the Keep operation if the workfile has been modified since the last Text or Keep. This can be useful in scripts that do Changes: by not Keeping files where no string changes occurred, you reduce the number of files that appear on the partial backup. To see whether your workfile is clean or dirty, do Verify Open.

File Modification Timestamp

When you use the Text command on a file, Qedit stores the file's modification timestamp in the workfile. If you try to Keep the file, Qedit compares the stored timestamp with the file's current timestamp. If they are different, it means the original file has changed since you first opened it. Qedit will alert you to the difference by displaying a message similar to the following:

Warning: Original file has been modified since the initial
Text or last Keep

The file timestamp can change for a number of reasons. Here are few examples:

  • Someone else might have been working on that same file with Qedit and saved their changes before you did.
  • The file could have been restored.
  • Maybe you used the file to test a program which modified the file in some way.

Because the timestamp message is just a warning, Qedit continues its processing. It then asks for Keep confirmation. If you answer "Yes", the file will be purged and you might lose someone else's changes. Qedit will also store the new modification timestamp.

If you answer "No", you should compare the contents of the file with your workfile and decide if it is safe to Keep your changes. This is one way to compare the files:

  • Keep the workfile under a different name
  • Use our Compare bonus program to display the differences between the original file and the new version you just created
  • Look at the report and separate the lines that you changed from the ones you did not touch
  • If needed, apply changes to your copy so you are not missing anything important

By default, timestamp checking on Keep is enabled. If you want to change this setting, use the Set Keep Checktimestamp command.

If you want to erase the saved timestamp, you can use the Set Keep Name command.

Newline Delimiters

Normally, lines in a UNIX file are terminated by a NewLine character. Even the last line of the file has to be terminated. For cases in which the last NewLine character is missing, Qedit is still able to read all the lines. However, if the file is saved back, Qedit adds a NewLine terminator. This makes the new file a little different than the original, even if you have not made any changes to it.

By default, Qedit inserts a Newline delimiter after each line. If you do not want Newline terminators, use the NOLF option. The only Newline characters written to the file are the ones included in the data. Using the Length option on the Text command disables the LF Keep feature (Set Keep LF Off). If you wish to override this, you can use the LF option.

Notes

When you Text a file and Keep it again, Qedit attempts to duplicate the original file. The form of the Keep file depends upon the current language and Set options, especially Set Keep. To see what the Keep file will look like, use Verify Keep.

Keep will retain the security of your existing file (i.e., the file's ACL) if you answer Yes to the "Purge old?" question.


Home Previous Next