Scans every BASIC (.B) file on a Larken disk for a search string of up to 256 characters or tokens and lists the file names and track numbers where it is found. A 120-byte machine-code routine at 44000 loads each track into a buffer; a routine courtesy of Richard Hurd finds the last track used. discan.Bp is meant to be compiled with Timachine (it runs very slowly uncompiled), and the discan loader runs the compiled code.
Listing only: it reads the disk track by track through the LKDOS routines and uses the Larken disk system throughout.
Published in Sinc-Link November-December 1991 (Discan: A Larken Utility for the TS2068).
Source Code
discan loader
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
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 10Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.