Classic Computer Magazine Archive COMPUTE! ISSUE 94 / MARCH 1988 / PAGE 86

Catalog To Text File

Jason Fuller

Apple II users can turn disk directories into text files with this BASIC program. Saved as text, disk catalogs can be edited, and then printed with a word processor or your own BASIC program. Works with DOS 3.3 disks only.

Unlike many computers, the Apple II doesn't provide a way to make text files from disk catalogs. "Catalog to Text File" is a BASIC program that solves this problem. When run, Catalog to Text File reads in a disk's directory and creates a text file that you can print and/or edit using almost any word processor.

By modifying the program to suit your needs, Catalog to Text File can be used to read the number of free sectors on a disk, to count the number of files on a particular volume, or to print out selected filenames in an easy-to-read format. This program works with unprotected DOS 3.3 disks only.

Getting Started

To begin, type in Programs 1 and 2 using the "Automatic Proofreader" program found elsewhere in this issue. When you're done, be sure to save a copy of each program.

Next, load and run Program 1. Program 1 writes a short machine language file to disk. This file is BLOADed into memory by Program 2, so it is important that the machine language file and Program 2 are saved to the same disk.

Creating A Text File

Load and run Program 2. The program prompts you for the volume number (or name) of a disk. Enter anything you wish, including letters. The characters that you enter become part of the filename used to save the disk's catalog.

When the computer prompts you, insert the disk that you wish to catalog and press Return. After the computer has read the catalog into memory, you are asked to insert the destination disk. Insert a disk and press Return. The catalog is written to disk with the filename CAT-VOL followed by the volume name that you entered earlier.

Using The Text File

The text file created by this program can be loaded by most word processors. From there you may edit it, reformat it, and print it out. When viewed, the catalog text file appears in the following format: .

Volume number, as entered by the user
Total number of used sectors
Total number of files on the disk
Filenames
     .
     .
     .
Filenames
The word *END*

It is possible to use this text file from within your own BASIC programs. To read the file, use the following subroutine:

58 1000 TEXT : HOME
8F 1010 INPUT "WHAT VOLUME NUMBER TO LOAD ";VOL$
20 1020 D$ = CHR$ (4) : REM CTRL-D
1C 1030 PRINT D$;"OPEN CAT-VOL " ;VOL$
B1 1040 PRINT D$;"READ CAT-VOL " ;VOL$
77 1050 INPUT VOL$
53 1060 INPUT USED
45 1070 INPUT NUM
11 1080 FOR X = 1 TO NUM
2E 1090 INPUT NAME$(X)
7C 1100 NEXT X
C3 1110 PRINT D$; "CLOSE CAT-VOL "; VOL$
DB 1120 RETURN

If you would like see the catalog text file sent to the screen, add these lines to the subroutine above.

0F 100 DIM NAME$(75): GOSUB 1000
A2 110 FOR X = 1 TO NUM
07 120 PRINT NAME$(X)
6B 130 NEXT X
91 140 END

Catalog To Text File

For instructions on entering these programs, please refer to "COMPUTE!'s Guide to Typing In Programs" elsewhere in this issue.