If you have any questions, comments,
or suggestions you would like to see addressed in this column, write to
"Readers' Feedback," COMPUTE!, P.O. Box 5406, Greensboro, NC 27403. Due
to the volume of mail we receive, we regret that we cannot provide
personal answers to technical questions.

IBM BASIC Directory
Can you tell me how to read and display the disk directory on an IBM PC
from within a BASIC program?

Kamal Ashour

There are two simple ways to
approach this. The first is simply to print the directory to the screen
at the appropriate time in your BASIC program. A second method would be
to read the directory into a string array for use by your program at
some later point. Here's a short routine that employs the first method:

This routine will
ask you from which drive (A: or B:) you want to read the directory. If
you have a single-drive system (drive A: only), remove the REM from
line 100. Here's another routine that uses the second method:

This routine reads
the filenames from the disk directory into an array named F$. One
advantage of this method is that you need to look only once at the
directory. Once the directory information is stored in a string, you
can extract the filenames whenever it's convenient and print them in
any format you like. With a little more programming, you could cursor
through the directory to access a particular file, sort the directory
entries alphabetically, catalog all your disks, or whatever. Again,
remove the REM from line 1000 if you have a single-drive system.