QUICK BASIC DIR ROUTINE

 BBS: Inland Empire Archive
Date: 06-05-92 (21:17)             Number: 185
From: MATT HART                    Refer#: NONE
  To: CHRIS HEALY                   Recvd: NO  
Subj: QUICK BASIC DIR ROUTINE        Conf: (2) Quik_Bas
 CH> string...  However you didn't include the source "Srchnext", or
 CH> if you did, I somehow missed it...

'
' SRCHNEXT.BAS  by Matt Hart
' Uses Interrupt 21H to find the next file matching a specification.
' Use SrchFile for the FIRST matching file before using this one.
' Note that after the Ecode - the file returned will be the same as
' the previous file.
'
    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
    DIM DTA as DTAType

' ---------------- Sample Code
    Srch$="*.BAS"
    CALL SrchFile (Srch$,File$,DTA,Ecode)   'You MUST call
    Print File$;Ecode                       'SrchFile FIRST
    DO UNTIL Ecode
        CALL SrchNext (File$,DTA,Ecode)
        Print File$;Ecode
    LOOP
    ' Ecode may return:
    '  2 = path invalid
    ' 18 = match not found
    END
' ---------------------------

SUB SrchNext (File$,DTA as DTAType,Ecode)
    DIM InRegs as RegTypeX
    DIM OutRegs as RegTypeX
    DIM F as string * 64
    F = Srch$+CHR$(0)
    InRegs.AX = &H4F00
    CALL InterruptX (&H21, InRegs, OutRegs)
    File$ = MID$( DTA.A, 31 )
    File$ = LEFT$(File$, INSTR(File$+CHR$(0),CHR$(0))-1)
    Ecode = OutRegs.AX
END SUB
---
 * 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