home *** CD-ROM | disk | FTP | other *** search
- 10 ' Reprinted from Micro/Systems Journal, Vol. 1, No. 1, March-
- 20 ' April 1985, article titled "Assembly Language Extensions for
- 30 ' MS-Basic" by Ron Kreymborg.
- 60 '
- 100 ' Directory reading program in Basic.
- 110 '
- 120 ' This program uses external assembly language routines
- 130 ' to assemble a string array containing matching entries
- 140 ' in the disc directory. Note that no new variables may
- 150 ' be defined between calling GET1ST and the last call to
- 160 ' GETNXT.
- 170 ' Ron Kreymborg
- 180 DEFINT A-Z
- 190 DIM FCB(20),DMA(64),DIR$(100),CR(2)
- 200 DEF FNA(A!) = PEEK(A!)+PEEK(A!+1)*256-2^16
- 210 A! = PEEK(7)*256+3
- 220 N = PEEK(A!)
- 230 IF N <> 4 THEN STOP
- 240 SPLIT% = FNA(A!+1)
- 250 GET1ST% = FNA(A!+3)
- 260 GETNXT% = FNA(A!+5)
- 270 SETDMA% = FNA(A!+7)
- 280 FLG=0 : CR(0)=0 : CR(1)=0 : E=0 : K=0 : U=0 : L=0è290 '
- 300 PRINT "Enter required match string as 11 characters, with"
- 310 INPUT " a '?' to match any character: ",A$
- 320 PRINT
- 330 IF LEN(A$) <> 11 THEN PRINT "Pardon?" : GOTO 300
- 340 PRINT "Matching entries:"
- 350 FCB$ = "."+A$
- 360 FOR I=1 TO 100
- 370 DIR$(I) = " "
- 380 NEXT I
- 390 '
- 400 ' Copy the specified filename into the FCB.
- 410 J = 0
- 420 FCB$ = FCB$+" "
- 430 FOR I=0 TO 5
- 440 J = J+1 : M = 1 : GOSUB 660
- 450 J = J+1 : M = 256 : GOSUB 660
- 460 NEXT I
- 470 CALL SETDMA% (DMA(0))
- 480 CALL GET1ST% (FCB(0),FLG)
- 490 '
- 500 E = E+1
- 510 IF FLG>3 THEN 560
- 520 GOSUB 720
- 530 CALL GETNXT% (FCB(0), FLG)
- 540 GOTO 500
- 550 'è560 FOR K=1 TO E-1
- 570 IF (K-1) MOD 4 = 0 THEN PRINT
- 580 PRINT DIR$(K);" ";
- 590 NEXT K
- 600 PRINT
- 610 PRINT
- 620 END
- 630 '
- 640 ' Load the ASCII sequence number into the correct
- 650 ' byte (specified by M) of the Ith FCB word.
- 660 B$ = MID$(FCB$,J,1)
- 670 IF B$ <> "." THEN FCB(I) = FCB(I)+ASC(B$)*M
- 680 RETURN
- 690 '
- 700 ' Extract each byte from the DMA buffer and load
- 710 ' them into the DIR$ string.
- 720 K = FLG*16
- 730 U = U+1
- 740 L = 1
- 750 FOR I=K TO K+5
- 760 CALL SPLIT% (DMA(I), CR(1), CR(0))
- 770 FOR J=0 TO 1
- 780 IF (I = K AND J = 0) THEN 810
- 790 MID$(DIR$(U),L,1) = CHR$(CR(J))
- 800 L = L+1
- 810 NEXT J
- 820 NEXT Iè830 RETURN