Re: directory tree

 BBS: Inland Empire Archive
Date: 11-28-92 (16:59)             Number: 348
From: BOB PERKINS                  Refer#: NONE
  To: JOHN GALLAS                   Recvd: NO  
Subj: Re: directory tree             Conf: (2) Quik_Bas
 JG> Yeah, but I'd rather have QB code, most likely using interrupts
 JG> to read the files.

  You'll have to modify this to work with your program John.  Pass the
segment:offset of your DIMmed type to the findfirst
function.  This function will return -2 if you requested a
null filename or an illegal attribute.  Call findfirst
first, and if it returns 0 then proceed to call findnext
until it returns -1.  Store what data you want in an array
or ? from the TYPEd structure between each call.  If the
returned attribute doesn't match what you were searching
for, reject and continue on.  Hope this is compete enough.

 '$INCLUDE: 'qb.bi'
 DECLARE FUNCTION findnext% ()
 DECLARE FUNCTION findfirst% (filename$, SearchATTR%, segment%, offset%)
 TYPE DTA
   extra AS STRING * 21
   attributes AS STRING * 1
   filetime AS INTEGER
   filedate AS INTEGER
   filesize AS LONG
   filename AS STRING * 13
 END TYPE
 DIM DTA AS DTA

 FUNCTION findfirst% (filename$, SearchATTR%, segment%, offset%)
 DIM regsX AS regtypeX
 IF SearchATTR% > 63 OR SearchATTR% < 0 OR filename$ = "" THEN
   findfirst% = -2: EXIT FUNCTION
 END IF
 '
 regsX.ax = &H1A00
 regsX.ds = segment%
 regsX.dx = offset%
 INTERRUPTX &H21, regsX, regsX
 testname$ = filename$ + CHR$(0)     'make ASCIIZ filename
 '
 'do the initial findfirst call
 regsX.ax = &H4E00
 regsX.cx = SearchATTR%              'Search attribute(s)
 regsX.ds = VARSEG(testname$)
 regsX.dx = SADD(testname$)
 '
 'regsX.flags AND 1 will be true if an error occured.
 INTERRUPTX &H21, regsX, regsX
 IF regsX.flags AND 1 THEN findfirst% = -1 ELSE findfirst% = 0
 END FUNCTION

 FUNCTION findnext%
 DIM regsX AS regtypeX
  regsX.ax = &H4F00     'FindNext Call..
  INTERRUPTX &H21, regsX, regsX
 IF (regsX.flags AND 1) THEN findnext% = -1 ELSE findnext% = 0
 END FUNCTION



--- Msg V4.5
 * Origin: Reciprocity Failure  (1:124/4115.236)
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