'=========================================================================== ' Subject: READING FILES FROM DIRECTORY Date: 08-16-96 (20:11) ' Author: Ronald Kas Code: QB, QBasic, PDS ' Origin: FidoNet QUIK_BAS Echo Packet: DOS.ABC '=========================================================================== ' > Does anyone know how to get the list(s) of files in a certian ' > driectory?? Without using the shell "dir" command?? can you use the ' > bois absolute disk read to read the fat table?? I know there are ' > simpler ways to do this, but I am wondering how the DIR command does ' > it... Such as to write my own, with out ANY shelling.... ' It is not so easy, but it can surely be done. ' You have to use an Interrupt to get the DTA of a file. ' Here is an exemple (I don't know if it works in QuickBasic, but I know ' it works in Qbasic. So if it doesn't work in QuickBasic, try it in ' Qbasic.) DECLARE SUB ReadFiles (pad$, masker$, Bestanden$(), BestLengte&(), BestAantal%) DECLARE SUB ReadData () DECLARE FUNCTION Interr% (num%, AX%, BX%, CX%, DX%) DIM Bestanden$(200), BestLengte&(200) DIM SHARED MS%(30) CLS ReadData ReadFiles "", "*.*", Bestanden$(), BestLengte&(), BestAantal% PRINT PRINT BestAantal%; "Bestandengevonden" FOR i = 1 TO BestAantal% PRINT Bestanden$(i), BestLengte&(i) PRINT , NEXT i PRINT MS.Data: DATA 55,8b,ec,56,57 DATA 8b,76,06,8b,14 DATA 8b,76,08,8b,0c DATA 8b,76,0a,8b,1c DATA 8b,76,0c,8b,04 DATA cd,21 DATA 8b,76,0c,89,04 DATA 5f,5e,5d DATA ca,08,00 DATA # FUNCTION Interr% (num%, AX%, BX%, CX%, DX%) IF MS%(0) = 0 THEN PRINT "FOUT": END DEF SEG = VARSEG(MS%(0)) POKE VARPTR(MS%(0)) + 26, num% CALL ABSOLUTE(AX%, BX%, CX%, DX%, VARPTR(MS%(0))) Interr% = AX% END FUNCTION SUB ReadData RESTORE MS.Data DEF SEG = VARSEG(MS%(0)) FOR i = 0 TO 99 READ byt$ IF byt$ = "#" THEN EXIT FOR POKE VARPTR(MS%(0)) + i, VAL("&H" + byt$) NEXT i END SUB SUB ReadFiles (pad$, masker$, Bestanden$(), BestLengte&(), BestAantal%) DTA$ = STRING$(80, " ") AX% = Interr%(&H21, &H1A00, 0, 0, SADD(DTA$)) BestAantal% = 0 FileName$ = pad$ + masker$ + CHR$(0) AX% = Interr%(&H21, &H4E00, 0, 32, SADD(FileName$)) WHILE AX% < 18 f$ = MID$(DTA$, 31, 12) IF INSTR(f$, CHR$(0)) THEN f$ = LEFT$(f$, INSTR(f$, CHR$(0)) - 1) BestAantal% = BestAantal% + 1 Bestanden$(BestAantal%) = f$ BestLengte&(BestAantal%) = CVL(MID$(DTA$, 27, 4)) AX% = Interr%(&H21, &H4F00, 0, 0, 0) WEND END SUB