In the January issue of SDU I gave the listing for a routine able to store and access from a single disk an index of more file titles than most of us will ever get around to using (no. tracks/disk X no. files/disk). This DOSDEX routine is based on an adapation of the versatile SDOS menu-loader created by Roelof Mulder with several modifications by John Oliger.
The machine code for DOSDEX and other utilities listed below is that used in the menu-loader except that if it is poked into a 39-byte first-line REM the 8th byte must be an 8 instead of the 14 in the original listing which utilizes a fast FOR/NEXT definition. For those who have the menu-loader routine with the code source in a line 10 q$ definition, after creating a 39-byte line 1 REM the code may be moved from q$ to the REM by using LISTING 1. If starting from scratch the code may be put into a DATA line and READ used for the pokes.
Rather than “let your fingers do the walking” through the pages of DOSDEX, the AUTO-DEX in LISTINGs 2 and 3 (SEARCH and FILE_DEX) provides an automatic search for a given title among all those saved on a disk as c$ arrays. It provides the option of a full-title search when the search word is padded out to a length of 10 by characters or spaces, or a wild-card search can be made for any set of 1-9 consecutive characters found in a title. If the wild-card search word is to be found at the very beginning of the file title, entering one leading space before the 1-9 character search word will allow a much faster search to be made as is also done for a full-title search.
The main drawback to using a full-title search is that the search-word must be entered exactly as the title you want to find. You could turn your printer on and key <LET /P=0> to print out a hard copy of the titles as the data disk is made up–just in case your memory fails. But then that defeats the purpose of an automatic search if you have to eyeball your way all through the printout or else use DOSDEX to find how to enter the title!
Anyway, here’s how it works, if you’re interested. The AUTO_DEX search routine is saved to file 0 by <RUN 9999> and FILE_DEX is saved to file 1, also by <RUN 9999>. If you want a full display of individual files in FILE_DEX save mode, start with the listing as given for DOSDEX in the January SDU, and change line 526 to correspond with LISTING 3 which displays only the disk number, format title, and prompts. Lines 600-650 can be omitted in either case. The mod for line 526 is to to save as DATA c$() the catalog info from each file disk in a numbered sequence.
After these programs have been saved to your AUTO_DEX disk, label your file disks numerically if you have not already done so for DOSDEX and key <LOAD> with the AUTO_DEX disk in the drive. At the prompt, key <4> to load FILE_DEX. Insert file disk 1 in the drive and key an upper-case <C> for CAT. Return the AUTO_DEX disk to the drive and key upper-case <S> to save the directory data, and so on. As for DOSDEX, you could easily adapt the routine to use one drive for the index disk and the second drive to catalog your file disks.
To make an auto-search, key <LOAD> with the AUTO_DEX disk in place and any key except <4>. At the search-word prompt, if an exact-title search is to be made, make your entry, then add spaces to pad out its length to 10. If you hold down the space-bar for an auto-repeat, any extra spaces added to the title will be truncated to the correct length. Precede any wild-card set of 1-9 characters with one space if that character set occurs at the very beginning of the targeted file title. If the set occurs elsewhere in the file title the leading space is omitted. Then enter a null-string <ENTER> if it is a Basic listing, or <token-word> plus <n> or <$> to denote the type of file.
When a match is found with the search-string title, the file number and the formatted title of the required disk is displayed. When that disk is inserted the file may be loaded from it. In a search for a full-title or a leading character-set the drive will seldom stop running from one index file to the next but a random wild-card search will take a little longer. The string-slicing will not allow TIMACHINE to compile the wild-card search, but those who are into machine code and want the ultimate in speed could adapt Tom Woods‘ Profile search routine to do it.
Roelof has also written another very useful utility he calls Extractor that among other things moves selected files from one disk to another. This method is a much safer way of recovering unused disk space even when an erase-and-recover routine is available. When one sector is being re-copied to another on the same disk there is always the risk of a glitch corrupting part if not all of the disk data. While not nearly as elegant as Roelof’s Extractor, the MARK-MOVE routine (LISTING 4) adapted from his SDOS menu-loader provides the essentials to format a target disk and move to it the files selected from a source disk. Keying <SPACE> will mark a file for moving, a zero will unmark it, any other character will advance the cursor, and <ENTER> will commence the moves.
LISTING 5 is yet another adaptation of the SDOS menu-loader which uses the VERIFY function to check the integrity of each file on a disk. It might be in order here to discuss some DOS facts of life that, human nature being as it is, probably all of us are aware of but have neglected at times. To be on the safe side–and we’re talking about all magnetic media data storage now–it is recommended practice to use a three-tiered approach. This calls for at least two back-up copies, either disk and disk, or disk and tape, for any files that we don’t want to lose. The original is then used only when an update is added or when both the working and backup files become corrupted or lost. It is also good practice to periodically check these files, especially if loading errors are encountered on any disks done at about the same time or after the backups.
By their very nature, all magnetic recording media (including audio and VCR as well as DOS) begin losing some of their playback signal strength, particularly in the higher frequencies, from the instant any recording is made upon them. This occurs at a diminishing rate somewhat like an inverse logarithmic progression or “half-life” process. As this “clipping” approaches the level expressed in percentage on all labelled name-brand disks, it happens more slowly but, unfortunately, never quite stops at zero.
Of course, many other factors could cause loss of data. These include possible instantaneous damage by magnetic fields such as a speaker or nearby AC cord, or static voltage potentials such as those on the face of a TV or monitor CRT or even on your fingertips if you have walked across the room or shuffled your feet on a carpet in low-humidity conditions. Creasing or folding a disk, dropping something upon it or writing on the sleeve with too much pressure, or touching the exposed surface can ruin it. There is also the possibility of dirt on the drive-heads or dust, heat and humidity hastening a disk’s demise. Tobacco smoke is dangerous to the health of data as it is to the user’s. Because of greater data-density per unit of media area, quad density systems are more sensitive to all these factors than double density systems, particularly when the less-costly DD disks are used with a QD system, which most of us do at times.
As John Oliger noted in the first issue of SDU, SDOS users have an advantage over users of some systems because we get an audible warning whenever a disk sector fails to save/verify or load and must be re-tried. However, even with SDOS an infrequently-used file or backup disk might drop below a critical clipping level without our being aware of it. If ever a data failure is encountered on a disk that previously showed no problems, unless you have done so periodically it is time to check all disks formatted at or before the time when that one was done.
Unless you are turned on by such things as watching paint dry or keying in VERIFY /”name” file-type for every file on every disk, a routine like VERI-DISK will take some of the tedium out of doing this. After loading VERI-DISK, insert a file disk and then press any key to CAT it and start the verifying sequence. Any failed files will be displayed by name and number in the order they are stored on the disk.
Since the VERIFY function tries only one time before returning an error report when even one item of data fails, if it is done in time it is usually possible to re-save or move a file that doesn’t verify because of clipping. Because after extended non-use all magnetic media also loses coercivity, i.e., it takes a “set” and becomes less responsive to recorded signals impressed upon it, it is good practice to move the entire contents to another freshly-formatted disk. AFTER MAKING SURE ALL FILES HAVE BEEN MOVED SUCCESSFULLY this can become your new backup or work-disk, or else the original disk may then be re-formatted and the files moved back to it from the intermediate storage disk.
When the clipping level has become critical, data may still load OK on the drive used to save it but not on another, so it is a good idea to note the drive number on each disk label. If a disk will not load at all, John Oliger’s routine for restoring directory files (SDU issue 1) may work to salvage some if not all the files in instances where track 0 has become corrupted.
LISTING 1
1 REM 123 *39-byte MC is poked here* 23456789
5 LET a=VAL "PEEK 23635+PEEK 23636*256+5"
10 LET q$="(Load original menu-loader listing that has a q$ definition. Delete all lines except this one. Replace first + CHR$ VAL "14" with + CHR$ VAL "8" in the definition. Add the lines for this routine and <RUN>.)"
20 LET d=1
30 FOR n=a TO a+38
40 POKE n, CODE q$(d): REM To use a DATA line, READ p: POKE n,p
50 LET d=d+1
60 NEXT n
100 DATA 205,10,0,42,75,92,17,8, etc. : REM Not needed to transfer from q$
LISTING 2 (SEARCH)
1 CLEAR : LET n=1
5 PRINT #0;"Key 4 TO SAVE DATA index files OR any other key for AUTO_DEX": PAUSE 0: IF INKEY$="4" THEN LOAD /"FILE_DEX"
10 LET d=1
20 DIM c$(178,20)
30 LOAD /"1" DATA c$()
100 INPUT "Search-word: 1-9 CHR$ wild-card (plus 1 leading space if start of title) OR pad to ↑ arrow if full title-";s$'""""" DATA n DATA $ CODE ABS VAL ?",t$: IF LEN s$>10 THEN LET s$=s$( TO 10)
110 LET t=0: LET f=0: LET f=(1 AND t$=" DATA n")+(2 AND t$=" DATA $")+(3 AND t$="CODE ")+(4 AND t$="ABS ")+(5 AND t$="VAL ")
115 IF s$(1)=" " THEN LET s$=s$(2 TO ): LET s=LEN s$: LET t=1: GO TO 140
120 LET s=LEN s$
130 IF s<10 THEN GO TO 180
140 FOR /178
150 IF c$(n,1)=" RESTORE " THEN GO TO 400
160 IF c$(n, TO s)=s$ AND CODE (c$(n,11))=f THEN LET k=n: GO TO 600
170 NEXT
175 GO TO 400
180 LET p=1
190 FOR k=1 TO 178
195 IF c$(k,1)=" RESTORE " THEN GO TO 400
200 PRINT #0;AT 0,0;d
205 FOR /10-s
210 IF c$(k,n TO n+s-1)=s$ AND CODE (c$(k,11))=f THEN GO TO 600
230 NEXT
240 NEXT k
400 LET d=d+1: ON ERR GO TO 1000: LOAD /STR$ d DATA c$(): ON ERR RESET : GO TO 140*(s=10 OR t)+180*(s<10 AND NOT t)
600 PRINT s$;TAB 11;t$;" = search$"''c$(k, TO 10);" ";t$;" is file #";k,"on disk #";d;" -- ";c$(178, TO 16): PRINT #0;"Insert disk & key ENTER TO LOAD or any other key TO REPEAT": PAUSE 0: IF CODE INKEY$<>13 THEN GO TO 10
605 LET a=CODE c$(k,11): LET d$=c$(k, TO 10): IF NOT a THEN LOAD /d$
610 IF a=SGN PI THEN LOAD /d$ DATA n()
620 IF a=VAL "2" THEN LOAD /d$ DATA n$()
630 IF a=INT PI THEN LOAD /d$CODE
640 IF a=VAL "4" THEN LOAD /d$ABS
650 IF a=VAL "5" THEN LOAD /d$VAL
1000 ON ERR RESET : PRINT s$;" ";t$; FLASH 1;" NOT FOUND ": GO TO 10
2000 STOP
9999 CLEAR : SAVE /0
LISTING 3 (FILE_DEX)
1 REM 1234567890123456 MC goes here 123456789
2 CLEAR : DIM c$(VAL "178",VAL "20"): LET s=SGN PI: LET o=NOT PI: LET d=s
5 LET a=VAL "PEEK 23635+PEEK 23636*256+5": LET c=INT (a/VAL "256"): POKE VAL "23549",VAL "195": POKE VAL "23550",a-(c*VAL "256"): POKE VAL "23551",c: LET fi=USR VAL "23549": LET n$=c$(VAL "178", TO VAL "16")
300 CLS : IF n$(LEN n$)=" " THEN LET n$=n$( TO LEN n$-s): GO TO VAL "300"
320 PRINT AT o,o;" Disk#";d-s;": ";n$;#o;"Key: NEXT CAT SAVE #";d
510 LET a$=INKEY$: IF a$="" THEN GO TO VAL "510"
522 IF a$="C" THEN OPEN #2,"P": CAT : CLOSE #2: GO TO INT PI
526 IF a$="S" THEN LET d=d+s: SAVE /STR$ (d-s) DATA c$(): GO TO INT PI
528 IF a$="N" THEN INPUT " INPUT NEXT #";d: GO TO INT PI
530 GO TO VAL "510"
9999 CLEAR : SAVE /"FILE_DEX" LINE 2
LISTING 4 (MARK_MOVE)
1 REM 1234567890123456 MC goes here 1234567890
2 CLEAR : DIM c$(VAL "178",VAL "20"): LET s=SGN PI: DIM m$(VAL "177",s): LET f=VAL "4": LET t=VAL "10": LET o=NOT PI: INK VAL "7": PAPER o: BORDER o: CLS
10 DIM f$(VAL "6",s+s): LET f$(s+s)=" DATA n": LET f$(INT PI)=" DATA $": LET f$(VAL "4")="CODE ": LET f$(VAL "5")="ABS ": LET f$(VAL "6")="VAL "
20 PRINT AT o,t;"FILE-MOVER";#o;"Place source disk in DRIVE 0 & target disk in DRIVE 1 Key any CHR$ TO CAT source disk or key ENTER TO NOT CAT ": PAUSE o: IF CODE INKEY$<>VAL "13" THEN OPEN #2,"P": CAT : CLOSE #2
30 INPUT "": PRINT #0;" TO FORMAT target disk? y/n": PAUSE o: IF INKEY$="y" THEN INPUT " INPUT FORMAT ↑ title to arrow";a$: LET /d=1: FORMAT /a$: LET /d=0: OPEN #2,"P": CAT : CLOSE #2
40 CLS : PRINT #o;"Key:SPACE to mark CHR$ to review0 to revise ENTER TO START MOVE"
100 LET a$="": DRAW INK s;VAL "255",o: DRAW INK s;o,VAL "175": DRAW INK s;VAL "-255",o: DRAW INK s;o,VAL "-175"
200 LET a=VAL "PEEK 23635+PEEK 23636*256+5": LET c=INT (a/VAL "256"): POKE VAL "23549",VAL "195": POKE VAL "23550",a-(c*VAL "256"): POKE VAL "23551",c: LET fi=USR VAL "23549": LET row=s+s: LET col=VAL "9": LET n$=c$(VAL "178", TO VAL "16")
300 IF n$(LEN n$)=" " THEN LET n$=n$( TO LEN n$-s): GO TO VAL "300"
320 PRINT AT o,VAL "16"-(LEN n$/VAL "2"); OVER s; INK VAL "5";n$;AT o,VAL "8"; OVER s;"________________": PAPER o
405 LET L=o: LET f=s: LET c=INT (fi/VAL "18"): LET dif=INT ((fi/VAL "18"-c)*VAL "18"+VAL ".4"): LET loop=VAL "17"
410 LET q$="p": LET it=s: IF loop>=fi THEN LET loop=fi: GO TO VAL "425"
415 FOR i=s TO c: FOR m=o TO loop: PRINT AT row+m,t-f;a$;AT row+m,t-LEN STR$ it;it;m$(it);c$(it, TO t);" ";f$(CODE c$(it,VAL "11")+1): LET it=it+s: NEXT m: GO SUB VAL "500": NEXT i: FOR i=s+s TO VAL "19": PRINT AT i,t-f;a$: NEXT i: IF NOT dif THEN GO TO VAL "410"
425 IF f THEN FOR m=o TO dif-s: PRINT AT row+m,t-f;a$;AT row+m,t-LEN STR$ it;it;m$(it);c$(it, TO t);" ";f$(CODE c$(it,VAL "11")+1): LET it=it+s: NEXT m: IF loop>=fi THEN LET f=o
427 IF NOT f THEN LET it=fi+s
430 GO SUB VAL "500": GO TO VAL "410"
500 FOR L=o TO m-s: PRINT AT row+L,col; INVERSE s;">": IF q$<>"" THEN FOR a=s TO PI↑PI: NEXT a: LET q$=""
510 LET a$=INKEY$: IF a$="" THEN LET q$="p": GO TO VAL "510"
512 IF a$="0" THEN LET m$(it-m+L)=" ": PRINT AT row+L,col+SGN PI;" "
515 IF a$=" " THEN LET m$(it-m+L)="▒": PRINT AT row+L,col+SGN PI;"▒"
520 IF a$=CHR$ VAL "13" THEN GO TO VAL "600"
530 PRINT AT row+L,col-s-s;" ": NEXT L: LET a$=" ": RETURN
600 BORDER VAL "7": PAPER VAL "7": INK o: CLS : INPUT "Source & object disks in drives?Key ENTER TO START MOVE ";a$: CLS : PRINT FLASH s;" MOVING! DO NOT STOP till end "
601 FOR M=s TO VAL "177"
602 IF c$(M,s)=" RESTORE " THEN GO TO VAL "700"
605 PRINT AT t,t;"File: ";m
610 LET d$=c$(M, TO t): LET a=CODE c$(M,VAL "11"): IF NOT a AND m$(M)="▒" THEN MOVE /d$
615 IF a=s AND m$(M)="▒" THEN MOVE /d$ DATA
620 IF a=VAL "2" AND m$(M)="▒" THEN MOVE /d$ DATA $
630 IF a=INT PI AND m$(M)="▒" THEN MOVE /d$CODE
640 IF a=VAL "4" AND m$(M)="▒" THEN MOVE /d$ABS
650 IF a=VAL "5" AND m$(M)="▒" THEN MOVE /d$VAL
660 NEXT M
700 PRINT AT o,o,,AT t,t; FLASH 1;" MOVE OVER ": INPUT "Key ENTER FOR NEW CAT "'" Any CHR$ STOP ";a$: IF a$="" THEN RUN
710 STOP
9999 CLEAR : SAVE /"MARK_MOVE" LINE 2
LISTING 5 (VERI_DISK)
1 REM 1234567890123456 MC goes here 123456789
2 CLEAR : DIM c$(VAL "178",VAL "20"): LET s=SGN PI: LET f=VAL "4": LET t=VAL "10": LET o=NOT PI
10 DIM f$(VAL "6",s+s): LET f$(s+s)=" DATA n": LET f$(INT PI)=" DATA $": LET f$(VAL "4")="CODE ": LET f$(VAL "5")="ABS ": LET f$(VAL "6")="VAL "
20 PRINT AT o,t;"VERI_DISK";#o;"Place NEXT disk in DRIVE, then any key TO VERIFY ": PAUSE o: OPEN #2,"P": CAT : CLOSE #2
200 LET a=VAL "PEEK 23635+PEEK 23636*256+5": LET c=INT (a/VAL "256"): POKE VAL "23549",VAL "195": POKE VAL "23550",a-(c*VAL "256"): POKE VAL "23551",c: LET fi=USR VAL "23549": LET n$=c$(VAL "178", TO VAL "16")
210 ON ERR GO TO 800
230 FOR m=s TO VAL "177"
240 IF c$(m,s)=" RESTORE " THEN GO TO VAL "700"
250 PRINT #o;AT o,o;"File: ";m
600 LET d$=c$(m, TO t): LET a=CODE c$(m,VAL "11"): IF NOT a THEN VERIFY /d$
610 IF a=s THEN VERIFY /d$ DATA
620 IF a=VAL "2" THEN VERIFY /d$ DATA $
630 IF a=INT PI THEN VERIFY /d$CODE
640 IF a=f THEN VERIFY /d$ABS
650 IF a=VAL "5" THEN VERIFY /d$VAL
660 NEXT M
700 ON ERR RESET : FOR m=s TO f: BEEP .2,RND*35: BEEP .1,RND*15: NEXT m
710 PRINT #o;AT o,o;n$; FLASH 1;" VERIFY OVER "; FLASH 0,"Note failures--any key FOR NEXT ": PAUSE o: RUN
720 STOP
800 PRINT "Failed at #";m;" ";c$(m, TO t);" ";f$(CODE c$(m,VAL "11")+1): NEXT m
9999 CLEAR : SAVE /"VERI_DISK" LINE 2
ADDENDUM: Since sending the above mss. to Bill, response to the DOSDEX article indicates some were confused by the instructions. Sorry about that! If the 8th byte in your MC listing or the 8th definition in q$ is already an 8, don’t change any of the code to POKE it into the line 1 REM for DOSDEX or the above routines. Please note that in listings 3, 4, and 5, as well as DOSDEX, the respective values in lines 5 and 200 must be as given above for these listings, NOT as they are in the menu-loader. The original menu-loader values were set up to point to the VARS location of q$ in RAM, and so must be re-calculated if this q$ location is to be used for the code instead of the REM.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.