Routine to read directory

 BBS: Inland Empire Archive
Date: 07-07-92 (21:03)             Number: 199
From: MATT HART                    Refer#: NONE
  To: STEVE FREELAND                Recvd: NO  
Subj: Routine to read directory      Conf: (2) Quik_Bas
' SRCHFILE.BAS  by Matt Hart
' Uses Interrupt 21H to find a file matching a specification.
' Use SrchNext for the next matching file.
    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
    TYPE DTAType
        A as string * 42

    DIM DTA as DTAType
' ---------------- Sample Code
    CALL SrchFile (Srch$,File$,DTA,Ecode)
    Print File$;Ecode
    ' Ecode may return:
    '  2 = path invalid
    ' 18 = match not found
' ----------------------------

SUB SrchFile (Srch$,File$,DTA as DTAType,Ecode)
    DIM InRegs as RegTypeX
    DIM OutRegs as RegTypeX
    DIM F as string * 64
    InRegs.AX = &H1A00
    InRegs.DS = VARSEG(DTA)
    InRegs.DX = VARPTR(DTA)
    CALL InterruptX (&H21, InRegs, OutRegs)
    F = Srch$+CHR$(0)
    InRegs.AX = &H4E00
    InRegs.CX = 0
    InRegs.DS = VARSEG(F)
    InRegs.DX = VARPTR(F)
    CALL InterruptX (&H21, InRegs, OutRegs)
    File$ = MID$( DTA.A,31 )
    File$ = LEFT$(File$, INSTR(File$+CHR$(0),CHR$(0))-1)
    Ecode = OutRegs.AX

 * 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