Classic Computer Magazine Archive ANTIC VOL. 8, NO. 6 / OCTOBER/NOVEMBER 1989

Quick Directory

Easiest access to your disk contents

By Matthew Ratcliff

Access the directories of your disks while using BASIC, without exiting to DOS or needing to enter lines of code. With the Quick Directory file on your disk, a simple ENTER command gives you open sesame to directories of disks in any drive - in Atari DOS or SpartaDOS - without damaging your program in memory. This BASIC program works on 8-bit Atari computers with at least 48K memory and disk drive.

Time and time again I lose track of important filenames while in the middle of writing a BASIC program. It's a pain to save work in progress, go to DOS, get a directory listing, return to BASIC and then attempt to remember where I left off.

A simple BASIC routine can present a directory listing:

10 DIM A$(40)
20 TRAP 30:OPEN #1,6,0,"D1:*.*": GOTO 40
30 ? "ERROR ";PEEK(195):END
40 TRAP 70
50 INPUT #1,A$
60 ? A$:GOTO 50
70 END

However, entering all this code every time can get tedious. Making it part of a program in development helps, but it's easy to forget. The best solution is to run an assembly language utility from BASIC. But, this implies a USR routine because Atari BASIC will not allow us to make calls to DOS directly.

Quick Directory makes accessing a current directory listing quite simple. It will have no adverse effects on the BASIC program currently in memory.

GETTING STARTED

Type in Listing 1, QDIRMAK.BAS, check it with TYPO II, and SAVE a copy to disk before you RUN it.

Listing 2 contains the MAC/65 source code for assembly programmers and requires the MAC/65 cartridge. You do not need to type Listing 2 to use Quick Directory.

QDIRMAK.BAS is a BASIC Quick Directory maker. RUN it and the program prompts you to get a disk ready in drive 1. Some special text and data will be written to your disk in a file named D:QDIR.

The D:QDIR file contains two lines of BASIC code with an embedded assembly USR routine, without line numbers. Try the command:

ENTER "D:QDIR"

Or try the Atari BASIC abbreviated version:

E."D:QDIR

Almost immediately, the program will request you to specify the directory you want to see. Enter D8:#.BAS to see all the BASIC programs on the disk in drive 8, for example. Unlike Atari DOS command A, you can't just press [RETURN] to see a directory of the disk in drive 1. To see all the files on the disk in drive 1, type D:#.#.

Use QDIRMAK.BAS to write the Quick Directory QDIR file to any disk you're planning to use with BASIC, and you'll always be able to see a directory of your files from BASIC with this simple command.

To see what these two lines of code look like, remove the "REM" from lines 90 and 150 in QDIRMAK.BAS (Listing 1), and RUN the program again. (You may also wish to change the filename in line 70 to "D:QDIR.LST".) Type the NEW command, ENTER the new file, and LIST the program. All the odd control characters in the string assignment for A$ make up an assembly language USR routine. With these two lines of code in a program, a directory listing is as simple as "A=USR(ADR(A$))".

Quick Directory eliminates time-consuming commutes between Atari BASIC and DOS.

SpartaDOS users night notice that Quick Directory file listings are in the long format. This makes it easy to keep track of file size and date stamps, as well as names.

Now, whenever you forget an important filename, simply type E."D:QDIR to see a directory listing, in immediate mode. Note that you can get subsequent directory lists by entering A=USR(ADR(A$)) whlle still in immediate mode. However, this could be dangerous if you make a typographical error, or inadvertently zap the variable A$ with a NEW or LOAD command. The E"D:QDIR" command is the safest approach, and far simpler than trekking in and out of DOS.

PROGRAM NOTES

Listing 2 is the MAC/65 source code for Quick Directory. Assembly programmers should take note of the "conditional assembly" technique employed here. Note the equates in lines 40 through 60:

40 OBJECT = 1
50 COM = 2
60 CODE = OBJECT

When the variable name CODE is set equal to OBJECT, the code between the ".IF" in line 790 and the ".ENDIF" in line 910 is assembled. This creates an object file suitable for placing in a BASIC USR routine.

While developing Quick Directory, it was much easier to test the program from DOS. To make a version that is loaded and executed from DOS, simply change line 60 to:

60 CODE = COM

When CODE is set to COM, MAC/65 ignores all the code enclosed in the first ".IF", ".ENDIF" sequence noted above. The code between lines 1630 and 1660 is assembled, however. These lines generate the proper header to execute Quick Directory from DOS. This technique is a valuable debugging tool, especially when developing USR routines that require conversion to some BASIC compatible format before testing.

The rest of the MAC/65 program is made up of straightforward calls to the CIO to open files, close files, input strings, and display strings. Stuffing the number 128 into ICAUX2 (lines 1310 and 1320) starts the SpartaDOS long directory listing format. It has no side effects on Atari DOS.

Quick Directory eliminates many frustrating, time-consuming commutes between Atari BASIC and DOS. Since it runs in immediate mode, it consumes no valuable RAM. It does not gobble up Page 6 or 4, common hangouts of many USR routines. Enter QDIR the next time you require directory assistance in a hurry. A.

Matthew Ratcliff regularly answers users' technical questions on CompuServe's ANTIC ONLINE.

Listing QDIRMAK.BAS Download
Listing QDIR.M65 Download / View