BBS: Inland Empire Archive Date: 07-07-92 (21:04) Number: 200 From: MATT HART Refer#: NONE To: STEVE FREELAND Recvd: NO Subj: Routine to read directory Conf: (2) Quik_Bas
' ' SRCHNEXT.BAS by Matt Hart ' Uses Interrupt 21H to find the next file matching a specification. ' Use SrchFile for the FIRST matching file before using this one. ' Note that after the Ecode - the file returned will be the same as ' the previous file. ' 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 DIM DTA as DTAType ' ---------------- Sample Code Srch$="*.BAS" CALL SrchFile (Srch$,File$,DTA,Ecode) 'You MUST call Print File$;Ecode 'SrchFile FIRST DO UNTIL Ecode CALL SrchNext (File$,DTA,Ecode) Print File$;Ecode LOOP ' Ecode may return: ' 2 = path invalid ' 18 = match not found END ' --------------------------- SUB SrchNext (File$,DTA as DTAType,Ecode) DIM InRegs as RegTypeX DIM OutRegs as RegTypeX DIM F as string * 64 F = Srch$+CHR$(0) InRegs.AX = &H4F00 CALL InterruptX (&H21, InRegs, OutRegs) File$ = MID$( DTA.A, 31 ) File$ = LEFT$(File$, INSTR(File$+CHR$(0),CHR$(0))-1) Ecode = OutRegs.AX END SUB ~~ --- * 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