Classic Computer Magazine Archive COMPUTE! ISSUE 61 / JUNE 1985 / PAGE 10

Commodore Disk Patterns

I have just finished reading your article about pattern matching on the Commodore disk drive. In the last paragraph of the section labeled "New Patterns," you talk about loading just the disk title, its ID, and the number of blocks free from the directory. Your suggestion is to use a filename not on the disk, such as 0:#$&!%. I have found an easier way : Instead of the usual command LOAD "$",8, use LOAD "$$",8. On a disk with a large number of programs, you cannot use this twice in a row or you'll get a FILE NOT FOUND ERROR. If you load the directory normally (LOAD "$",8) after using LOAD"$$",8 you may use the latter command again.

George Sherman, Jr.

You've stumbled across a curious aspect of Commodore's disk directory system: a few words of explanation might be in order.

First: "$" is a legitimate filename. Try writing a short program and then saving it with SAVE "0:$",8. No problem; the file will save without any errors. You'll find it in the directory, but note that LOAD "$",8 brings in the directory, not the program. But you can still get the program with LOAD "0:$",8.

Second: You may pattern-match without using the drive designator, although this will give you trouble. If you load a directory with LOAD "$P*",8, you will get all files starting with the letter P. It's much better to command LOAD "$0:P*",8, which specifies the drive number. The reason for this is odd, and relates to the fact that the 1541 DOS (Disk Operating System) software was developed from that found in Commodore's older 4040 dual-drive unit. Single-slot Commodore drives don't know that they are single; they suspect that there's a second drive around somewhere (drive 1, which doesn't exist). So if you use type LOAD "$P*",8, the disk drive will correctly get the directory from drive 0, and then try for a directory from nonexistent drive 1! It won't get it, of course, but it's left in "drive 1 mode," and the next job it gets without a drive specification will try drive 1 first.

Thus, if you enter LOAD "$P*",8 again, the unit will go to drive 1, find no directory, and report FILE NOT FOUND. This won't happen if you command LOAD "$0:P*",8 since drive 0 is forced.

Let's put these two together. When you type LOAD "$$",8 you are really telling the computer to look for a file with a name of "$". Normally, it won't exist, so you'll get only the disk header and block count; but if you saved a file with that name as suggested above, you'll see it in the directory.