BBS: Inland Empire Archive Date: 05-12-92 (21:02) Number: 11 From: DON KROUSE Refer#: NONE To: RONALD DERKIS Recvd: NO Subj: Question Of The Day! Conf: (2) Quik_Bas
RD>How do you pull the dir from the current drive and load RD>it into a array with RD>out it apearing on the screen? A simple question but one that has puzzeled RD>everyone! It's not very elegant, but I think it'll do what you want. Let me know. Append the long line that ends with "_" to the line above it. Don ====================================== cut ==================================== DEFINT A-Z DECLARE FUNCTION GetFileCount& (filespec$) DECLARE SUB PrintFast (Rows%, Col%, Msg$, atrib%) TYPE DirType FileName AS STRING * 8 FileExt AS STRING * 5 FileSize AS LONG END TYPE DIM Info(100) AS DirType CLS FOR x = 1 TO 25 '---- Fill screen with a pattern PrintFast x, 1, STRING$(80, "X"), 31 NEXT x PrintFast 6, 15, " Enter the file and path spec ", 95 LOCATE 6, 46: COLOR 14, 5: INPUT ; filespec$ '---- Shell to dos and redirect a directory into a file SHELL "dir " + filespec$ + ">dir.txt" '---- Open the file OPEN "C:\bc7\bin\dir.txt" FOR INPUT AS #1 total# = 0: count = 1 '---- Get info from the file into an array of variables DO WHILE NOT EOF(1) LINE INPUT #1, DirInfo$ Info(count).FileName = MID$(DirInfo$, 1, 8) Info(count).FileExt = MID$(DirInfo$, 10, 3) IF MID$(DirInfo$, 14, 5) = "<DIR>" THEN Info(count).FileExt = "<DIR>" Info(count).FileSize = 0 ELSE Info(count).FileExt = MID$(DirInfo$, 10, 3) Info(count).FileSize = VAL(MID$(DirInfo$, 13, 10)) END IF '---- Keep a running total of file sizes total# = total# + Info(count).FileSize count = count + 1 LOOP CLOSE #1 PrintFast 14, 5, "The screen should not have changed while the DIR info_ was being obtained", 46 PrintFast 14, 23, "NOT", 202 PrintFast 25, 22, "Press any key to display the directory", 206 SLEEP ' wait until a key is pressed before printing DIR information CLS '---- Print the directory info to the screen PRINT "Directory of "; filespec$ PRINT FOR i = 6 TO count - 2 PRINT Info(i).FileName; " "; PRINT Info(i).FileExt; PRINT USING " ########,"; Info(i).FileSize NEXT i PRINT " ------------" PRINT USING "Total #########, bytes"; total# SUB PrintFast (Rows%, Col%, Msg$, atrib%) place% = ((((Rows - 1) * 80) + Col) - 1) * 2 DEF SEG = &HB800 FOR i = 1 TO LEN(Msg$) POKE place%, ASC(MID$(Msg$, i, 1)) POKE place% + 1, atrib place% = place% + 2 NEXT i DEF SEG END SUB --- * Origin: Silver Lake Systems * Bothell, WA (1:343/58)
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