REPRINT FROM: BoSTUG Sinclair/Timex Newsletter, September/October 1988
More than once, my QL has mangled a long Quill document through poor disk or microdrive I/O. Either I removed the cartridge before closing a file, or the QL tried to write part of the file to a non-existent track on the disk or the QL crashed. The result is the same – any attempt to reload the file into Quill results in a File I/O Incomplete error, disasterous if you forgot to periodically backup your work.
One such encounter forced me to take a deeper look at how Quill files are stored. I could do this with “BGET”, which reads a single byte from a file. Most disk systems and toolkits have this command.
I used BGET to print out the numeric value of every character in my partially-corrupted Quill file to learn its structure and so recover at least part of it.
The most striking discovery was that Quill files use the Null character [CHR$(0)] in place of Carriage Returns. I also noticed that a good portion of the Quill file is formatting information, stored towards the end of the file. It is mostly strange control characters. All the text was present, but some formatting information was cut off during the incomplete SAVE.
I tried renaming the file with a _LIS extension and importing that, but Quill didn’t like the NUL’s and stopped importing the file at the first occurance of a NUL.
So I had to figure out a way to extract the ‘text’ portion of my document and re-write it as straight ASCII. BPUT came to the rescue and the result is the listing below. In a nutshell, the program reads a byte from the damaged file in channel #5. If it is a null, it’s changed to a carriage return [CHR$(13)]; if a control character (less than SPACE [CHR$(32)] but not CR), it is changed to a space. Otherwise, it is a regular ASCII character and left as is.
The now ASCII character is written to the new file in channel#6. The character is also printed to the screen so you can watch as it goes through the file. Then the loop repeats for the next character until there are no more characters to read. What is left is a plain text file which can be imported into Quill. I was able to recover a 15 page document this way, though it took about ten minutes to do so.
Hopefully you will never need to use this utility, but if you do, here it is.
10 REMark "Filesaver"
20 REMark Corrupted Quill file
30 REMark recovery utility
40 REMark by Jim Rodlin
50 REMark Requires Toolkit
60 REMark commands BGET & BPUT
80 REMark In the public domain
90 REMark Attribution requested
100 FLP_EXT: REMark or TK2_EXT
enable extended command set
110 CLS
120 OPEN#5, "mdv2_MYFILE_doc"
: REMark file to save
130 OPEN_NEW#6, "mdv1_BBS_lis"
: REMark output ASCII file
140 REPeat loop
150 BGET#5, a%: REMark get byte
and put in a%
160 IF a% =0 THEN LET a% =13
REMark convert null to CR
165 REMark replace all control
chars with SPACE
170 IF a% <32 AND a% <>13 THEN
LET a% =32
180 REMark print character to
screen for visual feedback
190 IF a% =13 THEN PRINT
: REMark Carriage Return
200 IF a% <>13 THEN PRINT
CHR$(a%);
210 BPUT#6, a%: REMark write
ASCII byte to _LIS file
220 END REPeat loop
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.