1540/1541 Disk Housekeeping
This simple utility will help you clean up the clutter on your 1540 or 1541 disk drive. For VIC and Commodore 64.
If you experiment with different programming techniques and save each enhancement along the way, your disks tend to get cluttered with outdated routines. Using programming techniques employed by Jim Butterfield (COMPUTE!, April 1982 and March 1983) and Steven Smith (COMPUTE!, March 1983), this short program will help with your housekeeping chores.
Type in the program, SAVE it to disk, and then give it a try. To prevent a disaster, try it first on a disk which does not include any important programs or files.
Scratching And Unscratching Files
If you choose the Scratch option, a portion of the disk directory will be displayed—just enough to fit comfortably on the VIC screen along with the query "Scratch program?" If you do not wish to scratch any of the programs listed, press the N key and another portion of the directory will be presented. Repeat this procedure until the entire directory has been displayed.
If you want to scratch a file on the list, press the Y key. Then, type in the name of the file to be scratched and press RETURN. The file will be scratched automatically, and the program will restart from the beginning. Continue this process until all unwanted files have been removed from the disk.
When the entire disk directory has been presented, you can end the program by pressing the N key in response to the scratch question.
If the Unscratch option is chosen, the program collects all free blocks off the disk and displays the names of any previously scratched files. You are then prompted with a scratched file. Enter Y to unscratch it. Sometimes the file will be partially scrambled because other files have been written over the original file. In that case, a message is displayed indicating that the file is unrecoverable.
Abbreviated Directory Listing
Lines 10–40 set the screen color, display the title and begin the program. Lines 50–190 read eight filenames from the disk directory and print them to the screen. The file sizes and types have been eliminated from the screen display to make it clearer and more concise. If you wish to include them, make the necessary changes by referring to Jim Butterfield's article "The Confusing Catalog" (COMPUTE!, March 1983).
Lines 200–240 branch the program depending on whether or not you wish to scratch a file. Line 250 ends the program when all files have been displayed and the N key is pressed. Line 260 returns to the directory for more filenames.
Line 270 gets the filename which is to be scratched and ends the program if you accidentally hit RETURN before you type a filename.
The subroutine in lines 340–380 examines the filename you enter. If the filename is longer than ten characters, it abbreviates the name and adds "*" to the end. This is done so that the filename and the scratch command together will not be longer than one VIC screen line.
Finally, lines 290–330 use the "dynamic keyboard" technique described by Steven Smith in "Automatic Commodore Program Selector" (COMPUTE!, March 1983), to scratch the file and run the program again from the beginning.
Use PRINT# Abbreviation
If you have a VIC, be sure to abbreviate the command PRINT# (P,SHIFT-R) in line 310, to insure that the filename and the command together do not exceed the 22-character line length of the VIC screen. If they are too long, the RETURNS which are POKEd into memory in line 330 are not entered properly when the END statement is reached.
The Scratch portion of the program runs on the VIC (any memory configuration) and 64. Since the line length of the 64 screen is 40 characters, abbreviating the filename when it is longer than 10 characters should not be necessary. You may wish to modify or simply eliminate the subroutine in lines 340–380. Commodore 64 users who wish to display more than eight filenames on the screen at one time can adjust line 190 accordingly.
With a little experimentation, VIC users should be able to eliminate the necessity for the subroutine which abbreviates the longer filenames. Try using branch statements and a second routine for printing the "OPEN," "scratch," "RUN," and "cursor up" instructions in lines 290–330. Also try adding lines to validate the disk and reorganize the directory. Finally, add a few lines to read the error channel, to make the program more complete.
1540/1541 Disk Housekeeping
Refer to the "Automatic Proofreader" article before typing this program in.