Open Command [O]

Qedit 5.7 for HP-UX

Home Previous Next


Open Command [O]

Instantly opens or reopens a Qedit file for editing or browsing, as opposed to the Text command which creates a copy of a file for editing.

OPENfilename[,BROWSE|DEFER|NODEFER]

*

*-n

?

(Default: edit primary scratch file)

Qedit shuts the current workfile and opens filename. The filename must exist (see New and Text) and must be a Qedit workfile or scratch file. You cannot Open a Keep file - you must first Text it into a scratch file.

Open filename,Browse opens a workfile for browsing in Qedit. You can use the List command, including List-Jumping, Hold, Visual mode HH and ZZ, and any other functions of Qedit which do not modify the file. Open-Browse protects you from making unplanned changes to a file.

If you try to Keep the file with its original name i.e. you enter a Keep without a filename, you will get an error.

/Open workfile,browse
/Verify Keep
Set Keep Name txtfile
/K
File opened with Browse, please specify a Keep file name

You can still force a Keep by specifying an explicit filename as in:

/Open workfile,browse
/Keep txtfile
TXTFILE.DATA.ACCT,OLD 80B FA # of records=16
Purge existing file [no]? y

Open filename,Defer opens the workfile without write access, but acquires write access later if you attempt to modify the file. Set Open Defer On makes Defer the default and Open filename,Nodefer overrides that command.

It is important to remember that certain workfile attributes and settings are normally saved when the file is opened with write access. Some of these settings are the ZZ marker, the current line marker (*), and a new default Keep name modified with Set Keep Name. If you open a workfile in Browse mode, these settings are not updated unless the file is re-opened with write access.

To reopen the file most recently accessed, do open *; for the file before that do open *-1, then open *-2, and so. To select from a list of recently accessed files, do open ?.

Examples

/open mail             {want to edit Mail}
/c "stop"start" @
/open *                {reopen previous file}
/list all
/open ?                {select a recent file}
/visual
/open *-1              {select file before last}
/list "function"
/open *-2              {select file before that}
/hold 400/500
/open                  {edit scratch file}

Notes

Since you must Open a file before editing, any command that requires an Open file creates a scratch file if none is Open.

If you attempt to Open a file which is not a Qedit workfile, you see a message similar to the following:

/open qpart2
Error:  Cannot open a non-Qedit file.  Use Text command.

You need to Text this file, not Open it.

The Open Stack

Qedit maintains an Open-Stack of the ten most recently Opened files. One of these is always reserved for the primary scratch file. You can have up to eight extra scratch files (see TextJ and New), which take priority over named workfiles in the Open-Stack. To reopen one of these files, do an open ? command. Open ? prints the list and prompts for a relative file number, starting with zero for the most recent (same as Open *).

Open *-n allows you to open one of the recently accessed files directly. Open *-2 opens the third file in the list, since zero is the first.

When you open any file it moves to the top of the list and the other files are pushed down one position. The Close command shuts the current workfile and removes it from the list of recently accessed files. This is useful to stop desired file names from dropping off the bottom of the list. If the file is a scratch file, you are prompted to Discard Changes.

Set Open Defer On

If you use Set Open Defer On, the Open command does not acquire write access to a workfile until you make a change to it. The workfile is opened with read access by default, unless Qedit knows you are going to be writing to it (as when Text or Add force an Open). If you only browse through the file, the Last-Mod date does not change. This includes full-screen mode viewing. However, if you make any changes to the file or use Set Left/Right/Length /Lang, Qedit reopens the workfile with write access.

It is important to remember that certain workfile attributes and settings are normally saved when the file is opened with write access. Some of these settings are the ZZ marker, the current line marker (*), and a new default Keep name modified with Set Keep Name. If you explicitly open a workfile in Browse mode or use Set Open Defer On, these settings are not updated permanently unless the file is re-opened with write access.

You can override the current Set Open Defer value by doing Open filename,Defer or Open filename,Nodefer.

There are a few error conditions that may occur if you attempt to modify a file because now someone else can edit the file while you have it open. For example, you cannot obtain write access if someone else already has write access to the file. In Visual mode, you may see the error "Unable to reopen file with write access. Concurrent usage/backup?".

If "Error: File open by another Qedit Process" appears when you try to open a file, it means that someone else is editing the file.

If you are working in Visual mode, someone can delete the lines you want to edit after Qedit has displayed them on your screen. If this happens, Qedit does not update your screen and displays this error message: "File has changed since page last displayed. Another user?"

Crash Recovery

Qedit ensures the validity of workfiles after a system crash or program termination. It checks to see whether the file was properly closed the last time. If the file was in the midst of Renumber, Qedit completes the renumber. If the file was in the middle of a Text, Qedit clears the file so you can do the Text over again. In all other cases, Qedit prints a RECOVERY warning and searches through the file to eliminate any duplicate lines. After a RECOVERY, examine the area of lines that you were last editing. A few lines may be missing or out-of-date, but that is all.

File Modification Timestamp

When you use the Text or Keep commands on a file, Qedit stores the file's modification timestamp in the workfile. If you Shut the workfile to do something else, the next time you Open it, Qedit will compare the stored value with the file's current timestamp. If they are different, it means that the original file has changed either since you last worked on it or since the last time you saved your changes. 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. However, if you want to be sure you are not missing important data, you should compare the contents of the file with your workfile and decide if it is safe to continue editing your copy.

This is one way to compare the files:

  • Use Verify Keep and write down the default Keep name
  • 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 that you do not miss anything important

It is important to remember that certain Qedit commands will shut and open workfiles on your behalf. The timestamp warning might appear when you do not expect it.

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


Home Previous Next