Reprinted from Commodore World Issue #7
If you have a Commodore 128, you can ask for the message by commanding PRINT DS$ (DS stands for Disk Status), or you can just get the number with PRINT DS. If you have a Commodore 64, it's not quite as easy -- unless you have a "wedge" program tucked away somewhere in memory. More on wedges in a moment.
There's a message waiting after virtually every disk activity. It might simply say "OK"; after a command to scratch files, the message might report how many files were removed from the disk. When there's an error, the disk light blinks and the message tells you what's wrong: perhaps there's trouble reading a file, or it can't write data because the disk is full or the write protect tab is in place.
To get such a message, you must have an open channel to the disk's secondary address 15, and you must ask for data over that path. Many programs start with "OPEN 15,8,15" to make the connection; they subsequently call "INPUT#15,E,E$,E1,E2" to get the status information. Eventually, there's a "CLOSE 15" to close the channel; the close must take place only after all other files have been closed.
But you can't use an INPUT# statement as a direct command; it works only within a program. So on the 128 you must type PRINT DS$ to get the data, and on the 64 .. you have a problem. But the problem can be solved by means of a little program called "the wedge".
Wedge Programs
The name, wedge, comes from two facts. First, the extra code has to
be wedged (or squeezed) into the operating system. Secondly, the earliest
versions of the wedge used the greater-than symbol (">") as a trigger.
In early Commodore computers, this character could be typed without using
the SHIFT key. Later, the at-sign ("@") was favored for the job, since
it remained an unshifted keyboard character. Another reason that wedge-writers
don't care for the ">" character much is that it is sometimes "tokenized"
within Basic code so that it needs to be checked twice.
There are a lot of wedge programs around, freely circulating in the Commodore community. The original, recut to fit the 64, is "DOS MANAGER 5.1", can be found in the CompuServe CBMART forum, library 1 ("DOS- 51.BIN"), as well as many other places. You must load it with LOAD "DOS 51",8,1 and activate it with SYS 52224. After that, it will stay quietly in high memory until you type a line that begins with the "@" or ">" character. (There are other action characters, too, but those two are the important ones).
Commodore World readers are likely to have computers fitted with JiffyDOS. This comes with a built-in wedge, with commands similar to that of the original DOS wedge.
If you have a machine language monitor loaded in your 64, chances are that it, too, will perform wedge-type activities. SUPERMON, for example, does wedge stuff if you type a line starting with "@". If that's to be followed by other information, insert a comma (thus, "@,"...); the comma is an extra which is used to specify a drive other than 8, so that a line might start "@9,...". Exactly the same syntax is used by the built-in machine language monitor of the 128.
The list goes on. A clever software fast-loader by Eddy Carroll, called "TURBO.VDOS", makes the wedge part of the standard VERIFY command. Just type VERIFY and you'll get the disk status.
Sending Commands
Wedge programs can do more than get a status message from the disk
drive. They can also send disk "commands". The stuff sent over secondary
address 15 is not data to be written to a diskette; instead, it's a command
instructing the drive to do something.
Here's a popular command: scratch (delete) a file from the diskette. In standard 64 operation, we must do this in about three steps: open the command channel, send the command with PRINT#15 (say, PRINT#15,"S0:MYFILE"), and then close the channel. The wedge program does it in one step. Type @S0:MYFILE and the operation is under way. Some wedge programs automatically return a status; with others, you can type the "@" symbol to get this information.
There are many more commands that you can send to the disk; you'll find them listed in your disk user's guide. Table 1 shows details, but here's a quick list of popular ones, with their syntax:
Copy files: C0:NEW=0:OLD Join files: C0:JOINT=0:PART1,0:PART2 Delete files: S0:OLDFILE or S0:OLD* Rename file: R0:NEWNAME=0:OLDNAME Validate disk: V0 (do NOT use with GEOS disks!) Format disk: N0:NEWDISK,X5 Initialize drive: I0There are a couple of things to note here. First, getting a directory is NOT a DOS command. The wedge will do it for you, but it doesn't belong in this list; we'll deal with it later. Second, I've used the prefix "0:" to specify the disk drive wherever possible. Dual drives are rare, but it's useful to always specify this; it helps save the disk drive from becoming confused. (Really!).
There is one example of pattern matching shown above. We'll mention it again when we get to directories: here we go. Directories.
The wedge recognizes a command such as "@$..." as a request for a directory. This does NOT go over channel 15, but the wedge knows how to handle it.
Pattern matching can be a great help in looking at a directory. The two major pattern-matching characters are "?", which matches any single character, and "*", which matches all following characters. Thus, to search for all files whose names starts with "BA", you could type:
@$0:BA*To track files with names such as DING, DONG, and D4NG, you could use a pattern such as "D?NG".
There's another pattern that's less well known. It's used to select the type of file you're looking for. Here are some examples:
@$0:GR*=S - show sequential files, names starting with GR @$0:?=P - show program files with one-letter names @$0:*=U - show all USR type files.Again, I'm using that "0:" prefix. You'll find that things often work if you leave it out, but they will work better if you keep it in there.
One of the joys of wedge-generated directories is that they do not affect the contents of memory; the directory data goes to the screen only. That's a great feature when you have a program loaded, and don't want it disturbed.
Program Notes
Most wedge programs work only as direct commands that you type on the
keyboard; they can't be triggered from programs. That shouldn't be a problem,
since a well-designed program can do all the necessary commands and status
checks over channel 15 without the help of a wedge. The only part that's
a little tricky is directories: programmers have to work to read in one
of those. We'll leave the details to another time.
If you're writing a program that will perform disk access, you'd be wise to open the command channel as one of your first acts, and close it only when your program has completed all its file work. Closing the command channel causes all other files to be closed... which is usually not a good idea.
Some Extras
Wedge programs usually come with extra commands. Typically, these include:
slash, to load a program; up-arrow, to load and run a program; left-arrow,
to save a program. There may well be others: JiffyDOS, for example, comes
with a whole battery of extras including file-locking, sending data to
the printer, and viewing disk file data. Whatever wedge you happen to have,
it's useful to have documentation.
Commodore 128 owners may be a little spoiled by the Basic 7.0 commands that came with their machine. There are keywords such as COPY, CONCAT, HEADER, VALIDATE, RENAME and SCRATCH in their vocabulary, together with variables such as DS and DS$. When a 128 user starts to do wedge work, there will be a phase where the new terminology will seem uncomfortable. But it works well, and the wedge is in fact much more flexible. Table 1 may help with the translation. Stay Tuned.
If you haven't got a wedge, for heaven's sake go out and find one. I'm planning to talk about relative files soon; you'll find it very handy to have a wedge at that time. That way, there will be an easy way to check the status of your experimental relative file activities.
The "Plain Basic" commands shown that begin with PRINT#15 must be preceded by "OPEN 15,8,15:"; the "PRINT#15," is followed by the same style of command shown for the wedge, in quotation marks but omitting the starting "@" character. It's a good idea to follow up with a CLOSE 15.
The "0:" prefix to file names should not be used in Basic 7.0 commands; the prefix is inserted automatically as the command is performed. It's a good idea, however, to use it in wedge and plain Basic commands.