Directory Scrolling

 BBS: Inland Empire Archive
Date: 06-16-92 (20:42)             Number: 648
From: MATT HART                    Refer#: NONE
  To: DON MILLS                     Recvd: NO  
Subj: Directory Scrolling            Conf: (2) Quik_Bas
Here's a few routines for you.  The first three are for loading a string
array with filenames matching the search criteria (I.E.
"C:\BAS\*.BAS").  The fourth is a list box routine which
allows you to scroll through selections and select from
them.  Just combine the GETFILES with LISTBOX and you have
a scroll file directory from which to choose.  I'm posting
this in 4 messages.  Let me know if your system cuts them
off after so many lines - some do, some don't.  Since they
are big, I'd rather do it this way first.  The last one
also includes BIOS screen scrolling and screen save and
restore routines.

'
' 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)
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