BBS: Inland Empire Archive Date: 07-19-92 (19:49) Number: 29 From: JEAN CREPEAU Refer#: NONE To: ERIC FORD Recvd: NO Subj: Another Question Conf: (2) Quik_Bas
In a message to ALL, ERIC FORD wrote:
EF=> Hey, is there anyway I could get a file listing of certain files (like
any file with one of three extensions) without having to use
EF=> files "*.dat" : files "*.res" : files "*.con"
EF=> Maybe a string for each filename so I could remove the extension?
EF=> Sorry I'm a GWBasic programer who has never spent the time to convert.
Thanks.
Well, if you program in GW-Basic, I can't really help you. You have
to load a machine-language program into memory and it's very complicated.
If you use QuickBASIC. Just use the following functions.
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,inreg as regtype,outreg as regtype
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 find a file, you must:
1. X=FindFirst(filnam$,dta), where filnam$ is the name of your file (you
can specify an entire pathname like D:\TESTDIR\*.DAT with * and ?)
2. If X>0, FILE NOT FOUND; the file doesn't exist; end.
3. The filename (without * and ?) is in DTA.filename terminated by a NUL
(&h00) character. Store or display that filename.
4. X=FindNext
5. If X>0, there is no more file of that name; end.
6. Go back to step #3
You can also skip step #5 and go back to step #2 instead, if you do
not need a separate message or status for a file not found. Then the
message at step #2 should be `NO MORE FILES'.
Jean
---
* Origin: INTERACESS Montreal (QC) Canada (514) 528-1415 (1:167/280)

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