QB 4.5 & DOS

 BBS: Inland Empire Archive
Date: 09-14-92 (22:18)             Number: 361
From: MATT HART                    Refer#: NONE
  To: JASON SHARPEE                 Recvd: NO  
Subj: QB 4.5 & DOS                   Conf: (2) Quik_Bas
 JS>  Is there any way to get a directory listing into an array of
 JS> the current directory fast!.  I have used shell ""dir *.* >

' 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.
    '$INCLUDE:'QB.BI'

    DEFINT A-Z
    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)
Outer Court
Echo Basic Postings

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