Classic Computer Magazine Archive COMPUTE! ISSUE 80 / JANUARY 1987 / PAGE 73

Apple cards DOS 3.3 Wildcards

Mark Russinovich

By permitting wildcard pattern matching in filenames, this short utility adds power and flexibility to DOS 3.3 for the Apple II.

Unlike the DOS (Disk Operating System) found on the IBM PC and other computers, DOS 3.3 for Apple II computers does not allow wildcard pattern matching. A wildcard is a special character that can match any one or more characters in a filename. The question mark (?) character can match any single character, while the asterisk (*) can match any combination of characters. For instance, in an operating system that accepts wildcards, all of these commands would load the file HELLO from disk:


    In the second command, the question mark matches the first L in HELLO. In the third, the asterisk matches the characters LLO. Wildcards not only save typing time but can speed disk operations such as the deletion of a group of files with similar filenames.
    This article includes a BASIC program which creates a short machine language routine that will modify DOS 3.3 to allow the use of the ? and * wildcards. Type in and save the program; then run it. The program reads the machine language routine from DATA statements and stores it on the current disk in a binary file, WILDCARD. Because the program creates a file named WILDCARD, you must not use that name for the BASIC program. Use any name other than WILDCARD for the BASIC program.
    To install the wildcard machine language routine, load the HELLO program on the disk containing the WILDCARD file and add this line:


(If the current HELLO program already includes a line 10, you can change the line above to any unused line number.) Don't forget to resave the HELLO program after you have made the change. Once this has been done, reboot the computer. Once you boot up with a disk that installs the wildcard program, you should not use INIT to initialize new disks. If you want to initialize new disks, reboot using a disk that does not install the wildcard option.

Wildcards With Filenames
After you have booted a disk containing the WILDCARD file and the modified HELLO progam, you can use two wildcard characters in filename specifications. The asterisk can match the endings of filenames. This is extremely useful when you wish to do something with a file with a long name such as HELPER.FILE.1. Using the asterisk, you need to type in only a few characters plus the wildcard, rather than the whole name. If more than one file on the disk has the same beginning as the one you type, DOS matches the first one on the disk (except for the DELETE command; see below).
    Because the asterisk can match a group of characters, it's important to give DOS enough information to locate the file you want. For example, say that your disk contains the files HELLO and HELPER.FILE.1. If your HELLO appears first in the disk catalog, then the command LOAD HEL* loads HELLO rather than HELPER.FILE.1. The command LOAD HELP* loads HELPER.FILE.1 unless some other file beginning with HELP precedes that file in the catalog. To avoid unwanted results, make sure that the filename contains enough characters to uniquely identify the desired file.
    This wildcard differs somewhat from the standard * wildcard found on other versions of DOS. It must be the last character in a filename, and you cannot use the wildcard by itself. (The commands LOAD *ELP and LOAD * are both illegal.)
    The asterisk works somewhat differently with a delete command. If you type in DELETE HEL*, DOS deletes all files beginning with HEL, not only the first file. This feature permits you to delete a group of related filenames. For instance, DELETE HEL* deletes HELP, HELPER, HELPER.FILE.1, and any other file on the same disk beginning with HEL. Since this command can have drastic consequences, use it with extreme care.
    The second wildcard character is the question mark (?), which can replace any single character. This symbol may appear anywhere in a filename. To understand how it works, suppose that you wish to load HELPER.FILE.1 from a disk that also contains the file HELLO. The command LOAD ???P* loads HELPER.FILEA (assuming the disk contains no other files with a P as the fourth character). Again, when the wildcard character is used with DELETE, every file matching the pattern will be deleted.

Wildcards With Commands
The asterisk wildcard can be used to match DOS commands as well as filenames. Instead of matching the first filename in a disk directory, the asterisk finds the first matching command in the DOS command table. The table lists the order of DOS commands. At least one character must precede the asterisk, which must also be the last character in the command. Both command and filename wildcards can be used in the same line. For instance, the command L* HELP* loads HELPER.FILE.1. These features can also be used with the command PRINT CHR$(4) from BASIC.

Order Of DOS Commands

1. INIT 14. OPEN
5. CHAIN 18. MON
7. LOCK 20. PR#
8. UNLOCK 21. IN#
10. READ 23. BSAVE
11. EXEC 24. BLOAD
12. WRITE 25. BRUN

WILDCARD Filemaker

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

E4 10 FOR I = 38016 TO 38121: RE
      AD A: POKE I,A:X = X + A:
AC 20 IF X < > 14283 THEN PRINT
      ": STOP
3F 30 D$ = CHR$ (4): PRINT CHR$
      (4)"BSAVE WILDCARD,A$9480,
12 40 DATA 160,2,185,162,148,153
01 50 DATA 136,16,247,160,2,185,
C8 60 DATA 153,110,162,136,16,24
61 70 DATA 185,168,148,153,235,1
68 80 DATA 247,96,76,173,148,76,
45 90 DATA 76,206,148,234,234,23
88 100 DATA 201,170,208,3,76,6,1
6E 110 DATA 191,208,3,76,1,178,7
CD 120 DATA 177,145,64,32,201,17
71 130 DATA 96,104,104,32,205,15
C7 140 DATA 201,42,208,16,185,13
ED 150 DATA 4,200,76,212,148,169
CA 160 DATA 170,76,240,159,89,13
73 170 DATA 240,159