[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Re: Re-opening files



Some time ago, Tim Baehr mentioned that his re-open files routine
contains "bits and pieces of the DLG file, U2 file, MNU file, and
startup file" and asked "can you think of a simpler scheme?"

Well, I'm sure my solution is much less elegant and inclusive,
but I've been using it quite successfully for several years now.
I originally wrote it for III Plus, but with minor modifications, it now works in
Xy4 DOS as well. Since I'm by no means a dyed-in-the-wool
do-everything- yourself programmer, I thought that I would be
switching to the log/restore feature that was added to Xy4, but I
find that so far I still prefer my homegrown concoction. Just for
the record, here's a description of how it works:

Basically, it is made up of two not very bulky XPL programs
called
QUIT and RESTORE (some 2500 bytes and 1000 bytes in length), both
of which make use of a small text file called QUIT.LST residing
in the
XyWrite directory (if this file doesn't exist the first time QUIT
is run, it creates it). I have assigned QUIT to Ctrl-Q. When run,
QUIT first confirms that I really want to quit, giving me the
option to bail out if I have hit the key by mistake. In that
case, QUIT terminates, leaving an encouraging message such as
"Trudge on!" on the command line. (I use only the command line
and status line for messages, since they are extremely easy to
generate in XPL.) When I confirm that I want to quit,
QUIT runs through all open windows and asks me two simple
questions, namely whether I want to store the file and whether I
want to reopen it later.
The response to the first is straightforward. When I respond "Y"
to the second question, QUIT (using the VA commands for file
path, window number, and cursor position) stores information
about the file in QUIT.LST, in the following format:

file name: D:\WORK\SOMEFILE  window number: 1  cursor position:
99999

This is repeated for all open files. The first line of the
QUIT.LST file also contains information about the directory XY
was logged to when the quit routine was fired up. The final step
is to save the current set of save/gets as QUIT.SAV in the
XyWrite home directory.

The next time I start XyWrite, the last line of STARTUP.INT just
reminds me which key to hit if I want to run RESTART. I
originally had the program itself linked to STARTUP.INT, but
decided to separate them, so that I could easily run RESTART at
any later time as well. RESTART first calls QUIT.LST to the
screen and pauses, giving me the option to modify the list of
files to be reopened (an option I almost never use). When I hit
"C", it continues and reopens each file in turn, in the original
window and with the cursor at the original position. This is
accomplished by searching for the plain text information after
the keywords "file name:" etc., putting this information into
temporary save/gets and using these on the command line. (Since
window 8 at this time is being used by QUIT.LST itself, any file
that was previously open in window 8 will be moved to another
available window.) Finally, RESTART changes the logged directory
to the one shown at the beginning of QUIT.LST and restores the
QUIT.SAV set of save/gets.

That's it. As they say, I don't know 'bout you, but it works for
me.

-----------------------------------------------------------------
------
Wolfgang Bechstein

Technical translator            Japanese / English /
German
Chiba, Japan           Tel 81-43-461-5911 Fax
81-43-461-5910
-----------------------------------------------------------------
------