M. R. D'Amato
If you have inadvertently scratched a file (and who hasn't?) on the 2040 (DOS 1.0) or the 8050 disk drive you can easily recover the information if you avoid saving additional files on the disk. (For really bad (slipped?) disk problems, see Cones' more sophisticated file recovery program; COMPUTE! #10.) The task is easier on the 8050, so let's start there.
On The 8050
When a program file is scratched, the file identifier, located in byte #0 of the 30-byte file entry in the directory, is changed from 130 to 0. Also, the blocks in which the file was written are recovered by DOS for subsequent reuse. Program 1 does the following. It searches the directory for scratched files and presents them on the screen one at a time. Press key "N" if the scratched file is not the one you want. (Also press "N" if all zeros appear as the file name, but don't respond to the directory track and sector numbers, which are provided for your information.) When the desired file appears on the screen, press "Y." This results in changing the file label from 0 to 130 and depositing this value on the disk. If the directory is then accessed, the name of the scratched file will appear in the displayed directory, and the file can be loaded into memory.
It is essential that the file be reSAVEd or it will be again lost when DOS assigns one or more of its blocks to a subsequently saved file. Therefore, after recovering the file and loading it into memory you should (a) SCRATCH the file (to remove it from the directory) and (b) SAVE the file under its original or a new name. That's all there is to it.
And the 2040
The task is a bit more difficult on the 2040 with DOS 1.0 because the track number of the first data block is, like the file identifier, also set to 0. However, it is usually possible to infer the number of the initial track by examining the starting track numbers of the neighboring files in the directory. Program 2, which lists a block of data on the screen, is meant to help in this task. When prompted for track and sector, enter 18,1, the first directory block. If your scratched file is in this directory block, it can be identified by its name, which appears in ASCII format. The first two bytes of the block give the track and sector of the next directory block (18,4). The 30 bytes of the first file entry follow.
As already noted, byte 0 holds the file type. The track and sector of the first data block are located in bytes one and two, followed by a file name in bytes 3-18, padded with shifted spaces (160's). A total of eight file entries (separated by two zero bytes) can be contained within a directory block. If your scratched file is not in the first directory block, access the next directory block by running Program 2 and entering 18, 4, continuing the process as necessary.
After locating the lost file, compare the track and sector number of the first data block in the preceding and the following file entries. These values will often immediately suggest the number of the first track of the scratched file. Having inferred the initial track of the scratched file, add lines 145, 414, and 416 to Program 1, change T in line 170 to 18 and run the program. It's a good idea to work with a duplicate disk, just in case you have the wrong track number and cause DOS some confusion.
Sequential files can also be recovered by changing the CHR$ (130) in line 410 of Program 1 to CHR$ (129). As with program files, once the sequential file is recovered, the name of the original file should be scratched from the directory and the recovered file saved.
The omission of a disk-error handling routine in the program is a concession to simplicity. It seemed just as easy to rerun the program if anything went wrong, but it's simple enough to include an error routine if needed.
The 8050 recovery program also works for files generated by the Wordpro 4 word processor, which stores text as program files. In fact, it was the humiliation of having mindlessly scratched a couple of such files that led to the development of the present program.
For those of you who might want to poke around in murky BAM (block availability map), Programs 3 and 4 will illuminate things a bit by highlighting, in reverse field, the BAM bytes associated with a particular track (four on the 2040 disk and five on the 8050). In both cases, the first byte reveals the number of free blocks in the specified track and the subsequent bytes indicate their identity. Block zero is represented by byte zero of the second byte, block eight is represented by byte zero of the third byte, and so on. Not a very intuitive layout, but computers have little concern for such matters.
Because the DOS support program ("wedge") jumps into action when it sees the ASCII of >, /,↑ or @, it's best not to have the wedge concurrently in memory when using Programs 1-3 on the 2040 with DOS 1.0. This is not a problem on the 8050 and may be on the 2040 with versions of DOS > 1.0. As if in compensation, the 8050 (but not the 2040) may give a "70, no channels" error if the disk holding the scratched program is not accessed with a load or a directory command after initialization. If this occurs, simply display the directory and rerun the program.