Classic Computer Magazine Archive Article from Compute! magazine

Directory Plus For Commodore

Thomas C. Carlson

This utility program prints a comprehensive disk directory on the screen or a printer, giving you extra information about the files on your disks. The program requires a 1541 or 1571 disk drive and runs on the Commodore 64, 128, Plus/4, 16, and VIC-20 (with at least 8K expansion). A printer is optional.

Virtually every Commodore disk drive owner knows how to get a listing of a disk directory. The statement LOAD"$0",8 loads the directory into memory, and LIST displays it on the screen. To print the directory on a printer, type OPEN 4,4 before you load the directory, and PRINT#4:CLOSE 4 after the listing is complete. The normal directory listing—which includes the filename of each file, its file type, and number of blocks—is fine for everyday use, but inadequate for more advanced purposes, In many programming situations it is necessary to know the load address of a file or the actual track and sector where it begins. When many files are involved, discovering such information can be a tedious process.

"Directory Plus" solves this by automatically printing an expanded disk directory on the screen or printer. In addition to the usual information, the expanded directory includes the disk track and sector where the file begins, and the load address of the file (the address where the file usually loads into the computer's memory). The accompanying figure illustrates a Directory Plus printout for a typical COMPUTE! DISK.

Directory Plus Printout

Directory Plus works without modification on the Commodore 64, 128 (40- or 80-column screens), Plus/4, 16, and VIC-20 (with at least 8K expansion). Since the VIC-20 screen has only 22 columns, its directory display is less neatly formatted than the others; however, the printer output is exactly the same for all versions.

Program Setup

After you have entered and saved a copy of Directory Plus, run the program. It begins by asking whether you want to display the directory on the screen or a printer. Press S for screen output or P for printer output.

If you're using a printer, be sure it is connected properly and turned on before proceeding any further. Directory Plus is designed to work with the following Commodore printers: MPS-801, MPS-802, MPS-803, 1525, and 1526. As listed below, the program is set up to work with the MPS-802 and 1526 printers. If you have an MPS-801, MPS-803 or 1525 printer, remove the keyword REM from the beginning of line 20 (but leave the rest of the line intact).

The program also works as is with non-Commodore printers, but only if your printer/interface combination can emulate Commodore graphics mode exactly. In this case, you should probably remove the REM in line 20 to activate the Commodore graphics mode; however, some interfaces for non-Commodore printers may require that you send additional codes to the interface to put it in Commodore graphics mode. It may also be necessary to add a secondary address to the OPEN statement in line 790. Consult the manuals for your printer and interface if you are in any doubt about the capabilities of your system.

The program can easily be modified to work with printers that do not support Commodore graphics as well. Simply replace the graphics characters in lines 800-910 with spaces, or use dashes, asterisks, or any other characters you wish.

If you select the printer option when displaying the directory, a second prompt will appear asking you to select the printing width. Press S for a single-width (normal) printout, or D for a double-width printout. Many printer interfaces that support Commodore graphics do not support the graphics characters in double-width mode, so you may not be able to use the D option if you have a nor-Commodore printer.

Load Addresses

At this stage the program prompts you to insert the disk whose directory you wish to view. Press any key when the disk is in place. After a pause while the computer reads the disk directory, the program asks whether you want to see the load addresses of any files. To display the directory without any address information, press the 3 key. If you want to see the load address for every file on the disk, press the 1 key. To view load addresses for only selected files, press 2. When this option is selected, the program displays each filename in turn, allowing you to choose whether you want to see its load address; press Y to display the load address of the current file, or N to skip to the next file. Note that some files (data files, for instance) don't contain a meaningful load address. In such cases, no address is displayed.

If you choose to display load addresses, the disk drive spins for a few moments while it retrieves this extra information for each file. You should not continue past this stage until the drive is finished working (when using the 1541 drive, wait until the motor stops spinning; on the 1571, wait until the drive's busy light goes off).

After every prompt has been answered and the drive is at rest, the directory display begins. To slow the scrolling of screen output, hold down the CTRL key on the VIC or 64, the Commodore key on the Plus/4 or 16, or CTRL-S on the 128.

After the directory has been printed on the screen or printer, Directory Plus gives you the option of viewing the same directory again, or of changing disks and printing a directory for the new disk.

Directory Plus does not display information about deleted (DEL) type files. DEL files are rarely of interest; however, if you wish to view them, delete line 870 from the program. Another possible modification involves the drive number. Although the 1541 and 1571 drives are always addressed as drive 0, some Commodore-compatible dual drives include drive 1 as well as drive 0. To access drive 1 in a dual drive system, change the 0 to a 1 in lines 170, 180, and 640.

In general, Directory Plus works by opening the directory as a sequential file and bringing in the contents one character at a time with the GET statement. The manual that came with your disk drive contains additional information about the structure of the directory. For those interested in writing similar programs, here is a brief outline of the major segments in Directory Plus:

Lines Function

10-160 Initialization

170-230 Read header information

240-480 Read file information

490-700 Read load addresses

710-930 Print directory listing

940-1010 Repeat options

1020-1050 Cheek error channel