BBS: Inland Empire Archive Date: 05-30-92 (23:50) Number: 145 From: MATT HART Refer#: NONE To: JASON SHARPEE Recvd: NO Subj: QUICK BASIC DIR ROUTINE Conf: (2) Quik_Bas
JS> I need an assembly routine or qb code that will list the files
JS> on the drive and attributes into arrays.
' GETFILES.BAS by Matt Hart
' Uses SrchFile and SrchNext to load an array with file names.
' Also CountFiles so you can DIM an array to match the number
' of file names.
'
DEFINT A-Z
TYPE RegTypeX
ax AS INTEGER
bx AS INTEGER
cx AS INTEGER
dx AS INTEGER
bp AS INTEGER
si AS INTEGER
di AS INTEGER
flags AS INTEGER
ds AS INTEGER
es AS INTEGER
END TYPE
TYPE DTAType
A AS STRING * 42
END TYPE
' ---------------- Sample Code
Srch$ = RTRIM$(LTRIM$(COMMAND$))
IF Srch$ = "" THEN Srch$ = "*.*"
CALL CountFiles(Srch$,NumFiles)
Print NumFiles
if NumFiles=0 then END
REDIM Files$(0 to NumFiles) : Files$(0)=Srch$
CALL GetFiles(Files$())
For i=1 to NumFiles : Print Files$(i) : Next i
END
' -----------------------------
SUB CountFiles (Srch$,NumFiles)
DIM DTA as DTAType
NumFiles=0
CALL SrchFile (Srch$,File$,DTA,Ecode)
DO UNTIL Ecode
NumFiles=NumFiles+1
CALL SrchNext(File$,DTA,Ecode)
LOOP
NumFiles=NumFiles-1
END SUB
SUB GetFiles(Files$())
DIM DTA as DTAType
Srch$=Files$(0)
CALL SrchFile (Srch$,File$,DTA,Ecode)
C=0
DO UNTIL Ecode
Files$(C)=File$
C=C+1
CALL SrchNext (File$,DTA,Ecode)
LOOP
END SUB
Continued...
---
* Origin: Midnight Micro! V.32/REL (918)451-3306 (1:170/600)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET