BBS: Inland Empire Archive Date: 11-26-92 (22:51) Number: 394 From: FRANKLIN BEAL Refer#: NONE To: CRAIG RANDLE Recvd: NO Subj: DIR 1/2 Conf: (2) Quik_Bas
CR> Hi, I'm writing a program that needs to get the CR> files in a directory and >maybe load them into an array. I've tried the files command but I get >something that looks like dos's dir which is no good to me. Hi Craig, Back in May I absconded the following program originally written by Matt Hart to Richard Vannoy. ' ---------------------------- cut here -------------------------------------- ' ' 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 mathc the numer ' of file names. ' ' Modified by Franklin Beal to allow non-command line arguments, ' correct the NumFiles count, & Files$(n) display. ' the Files$(n) display now dumps extranious characters left in ' DTA.A by the previous InterruptX &H21 write to OutRegs. ' DECLARE SUB CountFiles (Srch$, NumFiles%) DECLARE SUB GetFiles (Files$()) DECLARE SUB SrchFile (Srch$, File$, DTA AS ANY, Ecode%) DECLARE SUB SrchNext (File$, DTA AS ANY, Ecode%) 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 Srch$ = COMMAND$ IF LEN(Srch$) = 0 THEN INPUT "File search string: ", Srch$ END IF Srch$ = UCASE$(Srch$) Dot$ = MID$(Srch$, INSTR(Srch$, ".")) CALL CountFiles(Srch$, NumFiles) IF NumFiles = 0 THEN END REDIM Files$(0 TO NumFiles) Files$(0) = Srch$ CALL GetFiles(Files$()): PRINT NumFiles FOR i = 0 to NumFiles - 1 Files$(i) = LEFT$(Files$(i), INSTR(Files$(i), Dot$) + 3) PRINT Files$(i) NEXT I ' ---------------- continued on next message - end of part 1 ------------ * SLMR 2.0 * Error 110 : CPU missing ! ... Error 220 : CPU fried ! --- WM v2.04/91-0012 * Origin: Com-Dat BBS Hillsboro, OR. HST (503) 681-0543 (1:105/314)
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