It sometimes happen that a user deletes a disk file, only to realize later that file is still needed. This program provides a simple means of recovering these files.
The file recovery process is based on the fact that even though the disk Directory shows no record of the file it is nevertheless still on the disk. A disk file ERASE command simply places a marker at the start of the file name in the directory track (0). The marker is the value ‘254’. If you were to do an inspection of file names on the directory track, using the utility ‘doctor.B1’, you would see that unused name cells and ‘erased file’ cells have this ‘254’ marker.
This program loads the directory track into a buffer area in the computer, searches the name cells for the desired file, and removes the ‘erased’ marker. The now-modified directory track 0 is then copied back onto the disk.
You should note that the success of this program depends on the erased file not having been over-written by a subsequently program SAVE. Being overwritten means that the tracks containing the actual program have been reused, and the file is most certianly lost. Sometimes a file may not be overwritten because there were lower-numbered tracks available for storage, in which case file recovery is still possible. The only way to know is to try.
100 REM File Recovery Utility for the LARKEN system
110 REM By G. Chambers 14 Richome Court Scarborough, Ont. CANADA M1K 2Y1
120 REM Use to recover an accidentally erased file
130 REM Data statements contain the "RHMDOS.C2" Code.
140 REM For use with the DSK400 system of 5090 bytes/track. Single-,double-,or Quad-.
150 GO TO 170
160 CLEAR : RANDOMIZE USR 100: SAVE "recovr.B1" LINE 170
170 RESTORE 210
180 FOR n=63000 TO 63104
190 READ a: POKE n,a
200 NEXT n
210 DATA 195,43,246,195,72,246,195,104,246,243,205,98,0,201,58
220 DATA 100,0,251,201,205,33,246,58,176,92,50,29,32,205,126
230 DATA 0,205,123,0,33,112,32,17,156,224,1,0,20,237,176
240 DATA 195,38,246,205,33,246,58,176,92,50,29,32,33,156,224
250 DATA 17,112,32,1,0,20,237,176,205,150,0,205,126,0,205
260 DATA 120,0,195,38,246,205,33,246,205,129,0,205,123,0,33
270 DATA 112,32,17,156,224,1,0,20,237,176,195,38,246,201,0
280 DIM e$(9): DIM a$(9): DIM c$(1): DIM b$(9): DIM d$(256)
290 LET trac=23728: LET nexttrack=63006: LET loadbuf=63000: LET savebuf=63003
300 BORDER 1: PAPER 1: CLS
310 LET a$=" RETURN "
320 PRINT AT 2,6; INK 2; PAPER 6;"LARKEN DISK UTILITY"; PAPER 1;,,TAB 5; PAPER 6;"Deleted File Recovery"; PAPER 1,,TAB 6; PAPER 6;"By George Chambers"
330 INK 3: PLOT 0,108: DRAW 0,62: DRAW 255,0: DRAW 0,-62: DRAW -255,0
340 INK 6: PLOT 8,114: DRAW 0,50: DRAW 238,0: DRAW 0,-50: DRAW -238,0: INK 7
350 PRINT AT 10,0;d$;AT 14,1;"Insert disk with deleted file"''TAB 2;"and Press any key to start": PAUSE 0
360 REM Search of tracks for erased file
370 INPUT "Enter the full name of the deleted file ";b$
380 POKE trac,0: RANDOMIZE USR loadbuf
390 LET f=PEEK 57520*PEEK 57521-1
400 POKE trac,1: RANDOMIZE USR loadbuf
410 PRINT AT 10,0;d$;AT 10,10;b$;AT 10,2;"Searching tracks for program";AT 13,8;"Track Program"
420 PRINT AT 14,9;"No. Name"
430 FOR n=1 TO f
440 IF n>1 AND PEEK 57500=0 AND PEEK 57501=0 THEN LET n=79: PRINT AT 10,0;d$;AT 11,1; PAPER 7; INK 2;"File name not found on tracks": PAUSE 0: STOP
450 LET d=n
460 FOR m=1 TO 9
470 LET a$(m)=CHR$ PEEK (57501+m)
490 NEXT m
500 PRINT AT 16,9;n;TAB 14;a$
510 IF a$=b$ THEN LET n=f
520 IF n<f THEN RANDOMIZE USR nexttrack
530 NEXT n
540 REM Search for deleted name in Directory
550 POKE trac,0: RANDOMIZE USR loadbuf
560 LET g=57524+d
570 POKE g,245
580 LET c$=b$(1): LET e$=b$(2 TO ): LET e$=" RETURN "+e$
590 FOR n=57688 TO 61088 STEP 34
600 IF PEEK (n+4)=0 AND PEEK (n+5)=0 THEN PRINT AT 20,3; PAPER 7; INK 2;"Erased Filename not found";TAB 9;"in Directory": PAUSE 0: STOP
610 FOR m=1 TO 9
620 LET a$(m)=CHR$ PEEK (n+m)
625 NEXT m
630 IF e$=a$ THEN LET a=n: LET n=61088: POKE (a+1),CODE c$: GO TO 640
640 NEXT n
650 LET m=a+11
660 POKE m,d
670 FOR n=1 TO 22
680 IF PEEK (m+n)=249 THEN LET n=22: GO TO 700
690 POKE g+n,245
700 NEXT n
710 PRINT AT 9,0;d$;AT 10,3;"Program has been restored"'''' PAPER 5; INK 2;"Remove WRITE-PROTECT tab from defective disk and install. "'''"' Press a key to save to track 0 ": PAUSE 0
720 POKE trac,0: RANDOMIZE USR savebuf
730 PRINT AT 11,0;d$;AT 13,9;"JOB COMPLETED";AT 15,10;"Press a key","to display recovered file(only)": PAUSE 0
740 PRINT USR 100: CAT b$,
750 STOP
1000: SAVE "recovr" LINE 100
1010 STOP
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.