Question Of The Day!

 BBS: Inland Empire Archive
Date: 05-13-92 (14:48)             Number: 95
From: JEAN CREPEAU                 Refer#: NONE
  To: RONALD DERKIS                 Recvd: NO  
Subj: Question Of The Day!           Conf: (2) Quik_Bas
In a message to ALL, RONALD DERKIS wrote:
RD=> How do  you pull the  dir from the  current drive and  load it into  a
    array with out  it apearing on  the screen? A  simple question but  one
    that has puzzeled everyone!

        Use the following subroutines:

deflng a-z
'$INCLUDE: 'qb.bi'

type filedesc
reserved as string*21
attr as string*1
filetime as integer
filedate as integer
filesize as long
filename as string*13
end type

dim dta as filedesc

declare function findfirst%(x$,dta)
declare function findnext%()

function findfirst%(x$,dta as filedesc)
dim inreg as regtype,outreg as regtype,temp as string*128
inreg.ax=&h1a00
inreg.dx=varptr(dta)
interrupt &h21,inreg,outreg
temp=x$+chr$(0)
inreg.ax=&h4e00
inreg.cx=-1
inreg.dx=varptr(temp)
interrupt &h21,inreg,outreg
findfirst=outreg.flags and 1
end function

function findnext%
dim inreg as regtype,outreg as regtype
inreg.ax=&h4f00
interrupt &h21,inreg,outreg
findnext=outreg.flags and 1
end function

        To read the directory, call FINDFIRST with the filename your search
(it can be *.*  for instance). The filename  is in DTA.Filename field.  You
put this field  in your array  and call FINDNEXT.  The next filename  is in
DTA.Filename field. And you continue  until FINDNEXT returns 1 (that  means
there is no more file to check in the directory. Example:

Redim Dir$(127)
P=0:R=FindFirst("*.*",Dta)
While R
        Dir$(P)=Dta.Filename
        R=FindNext
Wend

                Jean
---
 * Origin: INTERACESS Montreal (QC) Canada (514) 528-1415 (1:167/280)
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