Classic Computer Magazine Archive COMPUTE! ISSUE 41 / OCTOBER 1983 / PAGE 266

Commodore DOS Wedges: An Overview

Jim Butterfield, Associate Editor

Most Commodore machines have a small program called a "DOS Wedge" which allows convenient use of various disk commands. Recently, copies of this program have been in circulation without information; many users who have it don't know how to use it. Here are the details.

What It Does

DOS Wedge programs provide for three types of capability:

– the disk's error status may be checked with a simple command;

– a disk directory (or catalog) may be obtained without disturbing a program which has already been loaded;

– a number of "disk commands" may be easily transmitted to the disk.

How To Start The Wedge

Wedge programs are often self-relocating. If you LOAD the wedge program and say RUN, the program will find a spare place in memory and pack the DOS wedge system there. After this, you may type NEW and the wedge will remain in place: it's been packed into a safe part of memory.

Some wedge programs come in "pieces," or as a set of programs on the disk. The first program, called the "boot," loads in the others as necessary. This is usually the case with the C-64 Wedge, for example.

Commodore 64 and VIC-20 wedge programs often also come with a how-to program, explaining the system and how it works. Many PET/CBM wedge programs print brief instructions on the screen as they self-relocate.

For other systems, you may find it necessary to use the last resort of reading the instructions.

First Rules In Using The Wedge

DOS Wedge commands must be typed in as direct commands. You cannot include them as part of a program. This is deliberate: programs will run at full speed without the need to check for the extra wedge commands.

Wedge commands should start in column 1 of the screen. The primary wedge commands are flagged with either of two symbols:

> or @

The "greater than" sign was the original. It looks like a wedge and is partly responsible for giving the wedge program its name. On later Commodore computers, this character needed the shift key; to save finger work, the @ (at sign) character was allowed as an alternative.

A few supplementary commands which use other starting symbols are available. They tend to be less important, since their functions can be performed easily with conventional commands. The most common of these are:

/ – to load a program; and

↑ – to load and run a program.

Thus, a command such as /DOGLEG will cause a program named DOGLEG to be loaded from disk.

Pattern Matching

In many cases, a program name does not have to be specified exactly. We can give part of the name and use "pattern matching" to find one or more programs that match the name. The pattern matching characters are:

? – to match any single character; and

* – to match any stream of characters.

Thus, a command such as /DOG* will load the first program it comes to whose name starts with the characters DOG. This might include DOGLEG, DOGHOUSE, DOG, and DOGOOD. Similarly, a command such as /D?G will load a three-character name such as DIG, DOG, or DRG.

Pattern matching can be used for many DOS Wedge commands. You must not use it, of course, when you SAVE a program, since the program must have an exact name.

Disk Status

This is perhaps the most useful (and the briefest) DOS wedge command of all. Simply type the > or @ character, followed by the RETURN key, and you'll get the status of the disk.

Most of the time, the disk will not report an error, but will give you a message like: 00,OK,00,00. If there's an error, or immediately following a SCRATCH command (more on this later), you'll get a different message. Following a SCRATCH, you'll be told how many files have been removed from disk. If the disk is signalling an error condition, you'll be told what the error is.

Most of the time, the error will be an obvious one, and you'll spot the difficulty right away. You might have attempted to write to a protected disk, or one that is full. You might have tried to create a new file giving a name that already exists. You might be trying to read or load a file that isn't there. You won't need to translate the number if the disk reports 62,FILE NOT FOUND,00,00. Sometimes, however, the disk error number can give useful information; look it up in the manual.

4.0 Equivalent: Users with a 4.0 BASIC system can type PRINT DS$ and receive the equivalent information.

Non-wedge Equivalent: If you don't have a wedge, you'd need to write a program to open secondary address 15 and INPUT from that channel. (INPUT works only from within a program.) Get a wedge.

Directory Or Catalog

You may obtain a catalog from disk, without disturbing a program already loaded, by typing >$ or @$. If you have a dual disk (two drives ganged together in a single housing), you may specify the drive by adding a number, yielding commands such as >$0 or @$1. Many experienced users suggest that you'll do well to specify drive 0 for single disks: the zero in @$0 won't hurt and might help.

You may take a "specific" catalog by using a filename with pattern matching. For example, >$0:D* will give only programs whose names start with the letter D. @$0:??? will report programs with exactly three characters in their names.

4.0 Equivalent: The command CATALOG or DIRECTORY will produce a directory. There's no simple way to get a pattern match with this.

Non-wedge Equivalent: You'll need to get a directory using a LOAD "$0",8 command. This destroys the program you have in place. (Get a wedge.)

Other Disk Commands

By following the > or @ sign with command characters, you may send a number of special commands to the disk. We'll list them below.

4.0 Equivalent: Specific commands are often available, such as SCRATCH, COLLECT, or HEADER. We'll deal with them individually below.

Non-wedge Equivalent: You must do this by opening secondary address 15, and then sending the command as part of a PRINT# sequence. For example, >I0 could be matched with OPEN 15, 8, 15 : PRINT#15,"I0". This is no hardship since it can be done with direct commands. The wedge is slightly more convenient.

Initialize

The command >I0 or @I1 causes the disk electronics to "shake hands" with the appropriate disk drive for a smoother transfer of data. It shouldn't be needed, but can be most useful if you start encountering DRIVE NOT READY errors. On single disks, @I0 is recommended.

4.0 Equivalent: None. You'd have to use the secondary address 15 equivalent.

Header (Or New)

Watch this one: It's powerful, and will wipe the previous contents of a disk. @N0 : DISKNAME,JB will format the drive over all its tracks, using the ID of "JB", and will prepare an empty directory with the title "DISKNAME". This job will take a few minutes.

@N0 : ANOTHER will not format the disk. Instead, it will just wipe the directory and put the new title in place, in this case "ANOTHER". It only takes a couple of seconds to do this, but all your disk information will immediately disappear. The disk must have previously been formatted before this version of the command can be used.

You cannot use a disk until it has been formatted. Be very careful that all your working disks have different IDs (the two letter identifiers); this will give your disk-stored programs and files important protection against harm.

4.0 Equivalent: HEADER. The 4.0 system asks ARE YOU SURE? before it dives in and wipes the data from the disk.

Scratch

Removes one or more files from a disk and frees the directory and disk space. A command of @S0 : TURNPIKE removes the file called TURNPIKE, if there is one by that name on the disk.

You may use pattern matching, but watch it! A command of >S0:C* will remove all files which start with the letter C. A command of @S0:* will remove all files, giving the same effect as New, but slower.

4.0 Equivalent: SCRATCH.

Verify (Validate, Collect)

A widely misunderstood command. This causes the disk unit to try to rebuild its map of free blocks, removing incomplete files as it does so. It does not report errors; it just reconstructs the Block Availability Map (BAM), using information from the directory.

If you have somehow created an incomplete file, it will appear in the directory with an asterisk beside the file type (e.g., *SEQ). You should immediately remove it with @V0 in order to avoid complications. (Do not, repeat do not, try to scratch such a file.) You'll probably need to wait awhile: rebuilding the BAM often takes time.

4.0 Equivalent: COLLECT.

Rename (Name)

Lets you change the name of a file. To change WATER to ICE, you type @R0 : ICE = 0 : WATER. Think of the syntax as similar to BASIC: the value to the left of the equals sign indicates what has been changed.

4.0 Equivalent: RENAME… TO…

Copy

Lets you make a new copy of a program on disk. Most useful on dual disk units, but you can make an extra copy even when you have a single disk. A command such as C0 : DOG = 0 : CAT will make an extra copy of file CAT, naming the new copy DOG.

A lesser-known feature of the Copy command is that it allows two or more files to be put together (or "concatenated") into a single file. This can be done with a command such as @C0 : FRACAS = 0: DOG,0 : CAT which puts files DOG and CAT together into a single new file called FRACAS. This feature is most useful for data files, by the way; you can stick programs together, but the result won't be very useful.

4.0 Equivalent: COPY… TO…; or CONCAT… TO…

Duplicate (Backup)

Only for dual drives. Allows a disk to be copied, block for block, from one drive to the other. Dangerous! Be sure you specify the correct direction, or you're in big trouble. So @ D1 = 0 will make an exact copy of the information on drive 0 placing it onto drive 1. If you intended to go the other way, it's too late.

4.0 Equivalent: BACKUP D0 to Dl. The system does not ask ARE YOU SURE? It just goes ahead.

Other Commands

There are other commands that may be sent down the command channel, but I don't recommend their use with a wedge. In fact, I recommend careful study of the manual or sample programs before using them in any form.

There are several DOS wedges; it's impossible to cover details on each of them. But they have similar patterns.

Learning to use the DOS wedge effectively is almost the same as learning to use the disk effectively. More correctly, it's learning how to use the disk—easily and effectively.