To scan an entire disk looking for any string up to 256 characters or tokens. Best Compiled using Timachine.
This will probably have limited use but once in a while a need may arise to do a complete scan of a disk. This happened to me recently when I was trying to determine just which BASIC programs used certain code files appearing on a disk. Two examples of this: cat.CR did not ring a bell with me; also I wanted to check which files called up HCode.C1, one of the Larken code files. Both are on the Omnibus disk.
It seemed too tedious to load every BASIC file on the disk, a quad with a few dozen of them. Besides, why not let the computer do the work. I set to work writing the routine which I call <discan.Bp>; the listing is on the next page.
Let me explain some of the lines:
50-90 Command lines for Timachine use.
110 Initializes b$ to the same length as s$. DIM b$(LEN
s$) cannot be compiled as it changes length each
time it is used. So this line gets around that.
s$=search string; b$=string PEEKed from the buffer.
120-140 This subroutine gives a choice of doing another
search or ending the session.
142 The first entry point for the compiled program.
150 Loads machine code to transfer each disk track
into the buffer area (starting at 50000). This code
will reside at 44000 and contain DATA line values.
160 Prompt for input string. Part is in INV VIDEO.
170 <t>= the variable for track number. This line sets
this at zero and pokes this value into 43900 which
will be used by the code at 44000.
190 To a subroutine at 430 which will get the track
number of the last track used on the disk being
searched. (routine courtesy of Richard Hurd).
The variable x will signify the last track.
230 When the last track has been searched, the program
goes to line 120.
240- Track number is increased by one and search
320 continues. Each time a track is loaded into the
buffer, the first 24 bytes are evaluated to get the
end of DATA on that track; also, only tracks with
the extension .B in the file name will be searched.
340- The search starts at 50024 and continues to <end>;
410 this is the part that requires the program to be
compiled, even though using <end> contributes to a
speedier search. For those without the compiler,
the program will run albeit very slowly. Also, each
time the routine STOPs, it is waiting for a <drv>
number. Line 380 prints the file names and track
numbers when b$=s$. I did not bother allowing for
a TS2040 COPY sequence or a wide printer one, either.
It should be easy to add, if the mood moves you.
To make the program run properly, a loader-manager is required and its listing is given immediately below.
100 REM discan loader
110 POKE 23658,0
120 RANDOMIZE USR 100: CLOSE #3
130 RANDOMIZE USR 100: LOAD "discan.Cc"CODE 60000
140 PAPER 7: INK 9: BORDER 7: CLS : PRINT PAPER 6;"DISCAN: used to scan disk tracks for the presence of input strings (characters, TOKENs, &c)"
150 PRINT '"However, this routine does not distinguish between TOKENs and other uses for their codes. "''"For example, it will find not only PRINT but any occurrence of its code <245> that may be used within a program."''"Thus, the search string with a TOKEN should be accompanied by other characters, eg, PRINT #4."
155 PRINT '"The search string will also turn up if it exists in the variables area."
160 PRINT #0;"[ENTER]": PAUSE 0
180 CLS : INPUT "drv? ";drv: RANDOMIZE USR 100: GO TO drv
190 CLS : RANDOMIZE USR 60000
195 GO TO 220
200 CLS : INPUT "drv? ";drv: RANDOMIZE USR 100: GO TO drv
210 RANDOMIZE USR 60269
220 INPUT "1=more 0=quit";mq: IF NOT mq THEN RANDOMIZE USR 100: GO TO 4: RANDOMIZE USR 100: NEW
230 GO TO 200
9899 STOP
9990 RANDOMIZE USR 100: SAVE "discan.Bb" LINE 100
Warning! If your compilation does not produce 60269 as the second point of entry and you are certain that you have not introduced errors into the listing, then change line 210 to suit your Timachine printout.
discan.Bp
50 REM ! LIST
60 REM ! LPRINT
70 REM !INT +o,end,poke,t,i,sid,nt,blx,x,n,aq
80 REM !USR 60000
90 REM ! OPEN #
100 PAPER 0: INK 9: BORDER 0: CLS : POKE 23658,0: GO TO 150
110 LET b$="": FOR i=1 TO LEN s$: LET b$=b$+" ": NEXT i: RETURN
120 IF t=x-1 THEN INPUT "END OF SEARCH ( 19 spaces ) 1=another 0=quit ";aq: IF NOT aq THEN STOP
130 IF t=x-1 AND aq THEN CLS
140 STOP
142 REM ! OPEN #
144 GO TO 155
150 GO SUB 530: GO SUB 140
155 CLS : INPUT ;: PRINT #1;"insert disk"'" [ENTER] ": PAUSE 0
157 IF CODE INKEY$<>13 THEN GO TO 157
160 INPUT "SEARCH DISK FOR STRING (10 sp.) string? "; LINE s$
170 LET t=0: POKE 43900,t
180 GO SUB 110
190 GO SUB 430
220 PRINT INVERSE 1;s$; INVERSE 0; " found on: "
230 IF t=x-1 THEN GO TO 120
240 LET t=t+1: POKE 43900,t
250 RANDOMIZE USR 44000: RANDOMIZE USR 44006
260 INPUT ;
265 LET end=50024+(PEEK 50014+256*PEEK 50015)
270 DIM n$(9): FOR n=50002 TO 50010
280 LET n$(n-50001)=CHR$ PEEK n
290 NEXT n
300 FOR n=1 TO 8
310 IF n$(n)="." AND n$(n+1)="B" THEN GO TO 340
320 NEXT n
330 GO SUB 110: GO TO 230
340 INPUT ;: PRINT #0;"Searching ";n$;" Track ";t
350 FOR n=50024 TO end
360 IF CHR$ PEEK n=s$(1) THEN FOR i=1 TO LEN s$: LET b$(i)=CHR$ PEEK (i+n-1): NEXT i
370 IF b$<>s$ THEN GO TO 390
380 IF b$=s$ THEN PRINT n$;" track ";PEEK 50001: GO TO 400
390 NEXT n
400 GO SUB 110
410 GO TO 230
420 STOP
430 RANDOMIZE USR 44000: RANDOMIZE USR 44006
440 LET sid=PEEK 50020: LET nt=PEEK 50021: LET blx=sid*nt: LET x=1: IF sid=1 THEN LET x=2
450 FOR i=(50024+(2*nt-x)) TO 50024 STEP -x
460 IF PEEK i=245 THEN GO TO 480
470 NEXT i
480 LET x=i-50023
490 LET nt=x: IF sid=1 AND x/2<>INT (x/2) THEN LET x=x+1
500 LET nt=x
510 IF sid=1 THEN LET nt=x/2
520 RETURN
530 RESTORE 550: FOR o=44000 TO 44119: READ poke: POKE o,poke: NEXT o
540 RETURN
550 DATA INT 195,249,171,195,7,172,195,27
560 DATA INT 172,195,56,172,195,75,172,243
570 DATA INT 205,98,0,201,58,100,0,251
580 DATA INT 201,205,239,171,58,124,171,50
590 DATA INT 29,32,205,126,0,24,237,205
600 DATA INT 239,171,58,124,171,50,29,32
610 DATA INT 205,129,0,58,29,32,50,124
620 DATA INT 171,24,217,205,239,171,175,50
630 DATA INT 32,32,205,123,0,58,32,32
640 DATA INT 79,6,0,33,112,32,17,80
650 DATA INT 195,1,0,20,237,176,24,188
660 DATA INT 205,239,171,33,80,195,17,112
670 DATA INT 32,1,0,20,237,176,205,120
680 DATA INT 0,24,169,205,239,171,42,144
690 DATA INT 171,78,35,70,24,158,0,0
9988 REM ! CLOSE #
9989 STOP
9990 CLEAR : RANDOMIZE USR 100: SAVE "discan.Bp" LINE 9995
9992 STOP
9995 GO TO 10
Media
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.