Abstract MS-DOS | Exploring From Filer | MS-DOS Command Line | Command Editor | Command Template | Editing Keys | Commands | Arguments & Switches | Wild Cards & Directory Symbols | Shortcut Symbols | More Commands | Do What I Mean | Trouble With Args | Pausing & Canceling | Missing Commands | Files & Devices | MS-DOS File Name Characters | Identifying Files | Devices & Drivers | RAM Disk | Redirection & Piping | r_harvey home page

Mascotr_harvey


Exploring MS-DOS

This document is excerpted from the book Explorer's Guide to the HP95. This information is useful for everyone who spends any time at the C> prompt, not just Palmtop PC users.

Introduction

The DOS in MS-DOS stands for Disk Operating System. Operating disk drives is what MS-DOS is all about. We communicate with DOS (that's the shorthand way of saying MS-DOS) by typing instructions on the command line. These instructions tell DOS to do things like create, copy or delete files, and to run programs.

Applications programs also depend on MS-DOS for disk management. Even when a program is running (including the HP 95 built-in applications), DOS is in the background, handling requests for files, memory and other system-wide services. MS-DOS handles the internal gubbins, leaving the interesting parts to application programs.

The MS stands for Microsoft, the author and distributor of the operating system. PC-DOS is just about the same thing, behind an IBM nameplate.

Abstract MS-DOS

The language of MS-DOS is full of words like paths, pipes, templates, streams and switches, and a collection of rather strange single-character commands. When we're done here, these symbols really will mean something:

/ + * . : ? | > < \ ! " %

The DOS language is brief and easy to remember, but it's not English-like. Some people in the computer business take the word language too literally. They reason that if it's supposed to be a different language, it shouldn't look too much like English. Popular programming languages like C (pronounced "See") add an extra level of abstraction by representing lots of tasks by a single character; maybe we could call it low-rogrylphics (not to be confused with hieroglyphics).

For instance, in the C language the exclamation mark ("!") means not, while if you tack-on an equals sign it means not equals ("!="), and the star ("*") means different things depending on where it appears -- and depending on how many stars there are (C is a four-star language). The new-age version of C, called C++ (pronounced "See plus plus"), adds even more abstraction, but missed the opportunity of straightening up the original C obscurities, and even adds more (like a new colon-colon :: keyword). Luckily, DOS isn't quite that abstract.

Stepping off the soap box... Now, since the programming community can't make it easy on themselves, there's no reason to expect them to make it easy on us users. We really shouldn't blame programmers: they don't get out very often, and a diet of pizza, cola and candy can have deleterious effects on people.

A Little Less Abstraction

Shorter commands save typing. And they are, once you've committed them to memory, easy to read. Another coined term we'll introduce is brain-clock-cycles. Languages are symbolic representations of things and ideas. The goal of DOS' short-cuts is to make symbols recognizable quickly, and without having to pay too much attention -- cutting clock cycles.

You may be tempted to skip the section on redirection and piping, one of the most abstract aspects of MS-DOS (especially if you skipped the section on binary numbers). Please don't, because while you'll probably not need it often, it's the foundation and reasoning behind many of the heuristic-machinations we go through.

Exploring MS-DOS From the 95's Filer

Filer is a wonderful place to explore DOS' file chain. It displays a sorted list, and you can look at the contents of any file by moving the highlighted selector to the file name and pressing ENTER. The most powerful Filer command, though, is Goto (the F5 function key). Goto changes to a different directory, a disk drive, and can even view a file -- with a twist: the directory or file can even be hidden.

Let's look at a corner of your 95 you may never have seen before: the hidden \_SYS\ directory on drive C:. Press the F5 key, then at the "Goto: File or directory name:" prompt, type:

\_SYS

The screen shows the directory name followed by a new list of files. You can confirm that there are about 27 files in this directory (at least, in the English language HP 95); press MENU, then select Directory Status. Filer will display information about the disk and directory:

C:\_sys 
Subdirectories:           0
Files in directory:       27
Bytes in directory:       196479
Bytes remaining on disk:  122368
Volume label: 

Now press ESC to return to the file list. The first file in the directory is 1000.PCX, which you will recall is the picture of a $1000 bill. Now if you press ENTER to view the file, you won't see president Cleveland, but a screen-full of smiling faces, upside-down Ts, and random-ish characters. Press UP or DOWN to browse through the file; it doesn't get any more readable than this. Most of the files in this directory look just as garbled. These are binary files, containing information encoded in binary instead of ASCII text. Lotus 1-2-3 WK1 spreadsheets and program files are also binary, but you'll find text and messages here and there.

Files can also be hidden, just like the hidden C:\_SYS\ directory. The HP 95 includes several hidden files in the C:\ root directory. Press F5 again, and at the prompt type:

\ROMDUMMY.015

This large file is chock-full of the messages and prompts displayed by the HP 95's built-in applications. When you press ESC to return to the directory list, you're back in the root directory.

Notes About Filer

The MS-DOS Command Line

We can follow two similar courses to reach the MS-DOS prompt from the safe harbor of Filer: Press MENU then select System, or move the selector bar to COMMAND.COM in the file list then press the F4 function key. Both methods leave the same amount of memory available for MS-DOS applications.

(Type exit to return to Filer)

Microsoft(R) MS-DOS(R)  Version 3.22
            (C)Copyright Microsoft Corp 1981-1989.

C>

Pretty austere, isn't it? While you're at the DOS prompt, none of the HP 95 built-in applications are available; pressing the 123 key does nothing at all. You will have to return to the safety of the System Manager and Filer to gain access to the built-ins. To get back to Filer in a hurry, type EXIT then press ENTER.

Note: Remember to close all applications except Filer when you shell-out to DOS. If an application is open, the computer will remind us -- we really don't have any choice in the matter. This is just as well, since we can be assured that all data files are closed.

It's difficult to lose or corrupt data from closed files. Since all of the HP 95's built-in applications are closed when you exit to MS-DOS, there is little concern about losing data if a DOS program crashes--unless the crashed program corrupts the disk.

The MS-DOS Command Editor

The MS-DOS command line editor is a primitive contrivance. The editor remained virtually unchanged for the first ten years of DOS' existence (the command editor was finally updated it in 1991, when Microsoft introduced MS-DOS 5.0). If you find the editor balky and unfriendly, don't worry about it, millions of other people do too.

A thriving cottage industry offers enhancements or replacements for the DOS command line. The HP 95 Filer is a typical command line replacement: easy to use, but missing a few essentials. No matter how good the command line replacements may be, sometimes you need the flexibility of the MS-DOS command line; it's worth the time you'll spend getting to know it. Even if the built-in applications do everything you want from your HP 95 today, somewhere down the road you will still need to turn to the MS-DOS command line.

Note: The MENU, 123 and other special keys are unique to the HP 95. Since other computers don't have these keys, software is not designed to recognize them, so programs either will ignore the keys entirely, or the keys will be mis-interpreted as something completely different (and likely not very useful).

MS-DOS Command Template

One of the nicest features of the command line is the previous command you typed is available as a template you can use to type the next command. Many DOS users ignore the template and re-type each command; the small keyboard on the HP 95 encourages us to save keystrokes--that's the real strength of the template. Let's walk-through a few exercises using the template and the DIR command.

The DIR (short for directory) command lists information about files in a disk directory. The directory is similar to the table of contents in a book, listing chapters, and where you'll find them in the book. Every disk has a directory, the section of the disk that contains information about files and their size and location on the disk. DOS' DIR command lets us look at the table of contents of a disk. Using it is as typing the name on the DOS command line:

DIR

If the last command line began with DIR and you'd like to see another directory listing, pressing either the F1 template key or the RIGHT cursor key four times will bring-back the word and the space after it. Each time you press F1 or RIGHT, one character from the template is copied to the command line. Now, DOS will place the cursor at the end of the line so you can add the new file specifications.

DIR *.COM

If you mis-type a character, press Backspace or the LEFT cursor key to delete the typo. Remember that the cursor is always at the end of the line, so you'll have to erase everything, backing-up to the mistake, then retype the character.

When you press ENTER, MS-DOS will show a listing of all COM program files in the current directory. If you're in the root directory of the C: drive, DIR will always show at least two COM files: COMMAND.COM and TF.COM.

Suppose we were looking for CHKDSK, which we thought was a COM program. Apparently it's not, so we'll recall the command line, up to the dot, by pressing F1 six times. Watch the display: after each key press, DOS will copy another character from the template to the command line:

DIR *.

The cursor is at the end of the line, just past the dot. Now we can type the EXE file name extension then press ENTER to see the directory entry for CHKDSK.EXE (and any other programs with the EXE file name extension).

DIR *.EXE

Keep in mind the difference between the command line and the template: the command line is where you type new commands, while the template is where the previous command is stashed. As you edit the command line, you can copy parts of the template into the new command. Here's a summary of the template keystrokes.

MS-DOS Template Editing Keys

KeystrokePurpose
F1 or RIGHTCopy one character from template to the command line.
F2Copy the template, up to the character you specify.
F3Copy the remainder of the template.
F4Delete from current position to the character specified.
F6 or CTRL+ZPlaces an end of file marker (character 26) in the line.
BACK or LEFTDelete character before the cursor. Template is unchanged.
DELDelete a character in template at the cursor position.
INSInsert characters at cursor position in the template.
ENTERAccept the command line. Tells DOS to execute command.
ESCCancel the command line. Does not change the template.
ALT+CURSORALT plus any cursor key (or ALT+SHIFT and a cursor key) scrolls the HP 95 window around the full 80x25 display. ALT+ cursor key tracking is available only on the HP 95.

We'll talk about MS-DOS wild cards in a few minutes on page 48, but DIR is a prime candidate for using wild cards, so here's a preview. The F1 and F3 keys make it easy to use the previous command as a starting point for new commands. Say instead of EXE files, you want to see a listing of EXM files (those are the special HP 95 Application Manager compliant programs). Press F3 to recall the entire template:

DIR *.EXE

Now press LEFT or BACK to erase the E from the end of the line, then replace it with M. Finally, press ENTER.

Volume in drive C has no label
Directory of  C:\
File not found

What happened, we know there should be at least two EXM files? Remember, the HP 95 ROM includes System Manager versions of TigerFox and Hearts&Bones, which are in the hidden C:\_SYS\ directory. We're logged-onto the root directory of the C: drive, so we'll have to tell DOS where to look for the files.

Note: Unlike the HP 95 Filer program, DOS' DIR command does not sort file names in directories. Subdirectory names will not be placed at the top of the list. MS-DOS writes files to the directory in the order they are created; as files are added or deleted, the order of files in the directory will change. You might try using a utility program (such as Norton Utilities) to sort the directory, and write the sorted list back to disk, but some utilities may have a fit when they try to re-order files that are permanently burned in the HP 95's ROM.

Let's modify the command line to add the path so DOS will be able to find our missing files. First press F1 four times to recall the word DIR and the space. Now, press SHIFT+DEL (that's the equivalent of the INS key on the HP 95) to enter insert mode then add the directory to the command line:

DIR \_SYS\

When we move the cursor or recall anything from the template, the command line returns to overstrike mode. The rest of the command is still in the template, so we can press F3 to recall the remainder of the line:

DIR \_SYS\*.EXM

Now when you press ENTER, DOS will find the files in the \_SYS\ directory, and display their directory listings:

HB       EXM     6702   3-29-91   4:34p
TFOX     EXM     8315   3-18-91   1:54p

Instead of pressing F1 several times to copy the beginning of the template to the command line, this time let's try F2. This command requires an argument: the first character on the line that you don't want. DOS doesn't display the character you type, so it's time for some visualization. To copy the template up to, but excluding the file name extension, press F2 then E (the first character in the file name extension):

DIR \_SYS\*.

Now type the new extension. The on-line help files for the HP 95's built-in applications are in the \_SYS\ directory, so type the HLP extension:

DIR \_SYS\*.HLP

Note: The DEL key works on the template, not the command line (that's what the BACK and LEFT keys are for). Since the cursor is always at the end of the command line, there would be nothing to delete there, anyway.

Here's the last example of reusing the template. This is an outlandish way to save a few keystrokes, but follow through anyway, some of these maneuvers are quite useful. We'll look at the setup files (file names ending with ENV) in the C:\_DAT\ directory, so to recall up to the underscore in the template, we'll press F2 then S:

DIR \_

Now we'll delete the next three characters from the template by pressing DEL three times to delete three characters from the template. The display hasn't changed, but the next characters in the template are "\*.HLP". The default is over type mode, so we'll change to insert mode by pressing SHIFT+DEL (the insert mode key, again). Now type D A T:

DIR \_DAT

We still need the next backslash, star and dot from the template, so we'll press F2 followed by H to recall up to, but not including, the extension:

DIR \_DAT\*.

Now we can add the extension (ENV), then press ENTER to see the matching files:

DIR \_DAT\*.ENV

That's it, probably the most roundabout way to save a few keystrokes. In real life we would probably press F2 then D, then since the template is in overstrike mode anyway, we would just overwrite the SYS with DAT. The backslash character is a shifted keystroke on the HP 95, so we would probably press F2 again and type the remainder of the command, just as we did before.

If you aren't in the root directory, prefixing a drive letter to the file specification doesn't mean the root directory -- it just means the drive, without specifying any path, which means the current path. Say you're still in the C:\_DAT\ directory, this next command would seem to show the root:

DIR C:*.COM

It actually shows the files in the current directory! This is because it's possible to be logged-onto other than the root directory of more than one drive. If you're logged-onto the A: RAM disk, the C:*.COM path will show the matching files in C:\_DAT\. To be sure you get the root directory listing, you must specify the full path name; in this case, that means just adding a backslash:

DIR C:\*.COM

These exercises show the template as a powerful, yet goofy-looking tool. It's especially useful with the small keyboard and frequently shifted keystrokes of the HP 95. We copy the template to the command line, then we use the template editing keys to (usually) make the job easier.

Note: If you make a typing mistake and would like to start over again, yet still re-use the original template, press ESC to erase the command line. The command line will be cleared, but the template is intact. The template is versatile, but you're working in the dark. You can also use this feature if you've forgotten what's in the template. Press F3 to recall the entire line to the display, then press ESC to cancel; the cursor will move to the next line, but DOS will leave a copy of the template on the line above.

Note: With most versions of MS-DOS, the template from the previous command line is usually available, even after executing large applications programs.

One feature unique to the HP 95 is the longevity of the template. The previous command line is always available, even after you reboot the computer -- it just won't go away! In fact, when you first move from Filer to the DOS command line, you can press F3 to recall the previous command (which will probably be EXIT, the command you typed to return to Filer).

Almost miraculously, the HP 95 will recall the previous command line after a cold boot -- even if you've re-initialized the RAM disk (though not after you've enlarged the RAM disk, and reduced conventional memory). Just about the only way to get rid of the old command (short of entering a new one, but that's too easy) is to unplug the AC adapter, remove the batteries and let the computer sit for a few minutes until it's completely forgotten its purpose in life (and the contents of all of memory, and the C: RAM disk).

MS-DOS Commands

These commands are the language MS-DOS understands.

MS-DOS recognizes two basic types of commands: internal, built-in commands (such as CLS or EXIT, or as we've already discussed, DIR), and everything else (external commands like CHKDSK.EXE or user programs like TF.COM). External command is just another way of saying utility program. External DOS commands in program files are treated exactly like any other program. You can circumvent the confusion of what to call things by calling everything a command, or the more generic term: keyword.

If the MS-DOS command processor recognizes the keyword as an internal command, it carries out the request immediately. However if it isn't a command DOS recognizes, the command processor assumes it must be a program, so it searches the disk for a program file with that name to run.

The MS-DOS command processor recognizes three program file types for external commands: COM, EXE and BAT (short for command, executable and batch). MS-DOS searches for program file types in just that order; if you have two programs with the same name, but one has the COM file name extension and the other is an EXE, DOS will run the program with the COM extension. Say you create a batch file named TF.BAT, when you type the TF command -- even if you include the BAT extension -- DOS will run the version of TigerFox in the TF.COM program file anyway.

Note If you have experience with HP BASIC, you're used to running programs with a CALL or RUN statement. Since everything in DOS that isn't built-in is a program we call, preceding the command with CALL is unnecessary. There is a wonderful simplicity in DOS commands; no extra quotation marks or odd-looking delimiter characters, just a shorthand language. Many DOS commands have even shorter, abbreviated forms (like typing CD instead of CHDIR).

Arguments and Switches

Arguments are options we type on the command line following the keyword. These options modify how commands and programs work. MS-DOS passes the tail-end of the command line (called the Command tail) to programs without change. Each program recognizes different options, and some programs use none at all.

Switches are a type of argument, usually beginning with a forward slash ("/"), followed by one or more other characters. Additional arguments, like file names, are simply preceded by a space. MS-DOS interprets only redirection symbols, everything else is sent unchanged to the program or command -- the commands interpret these arguments.

As we've seen, the DIR command displays information about files. We can enter just the command alone on the line to see a simple directory listing:

DIR

MS-DOS will interpret this as meaning "Show me every file in the current directory." Here's a listing from the root directory of the HP 95's C: RAM disk:

 Volume in drive C has no label
 Directory of  C:\
COMMAND  COM      184   2-11-91  10:36a
CHKDSK   EXE     9680   2-11-91  10:37a
_CFLOW   WK1     4418   3-20-91   7:38a
_EXPENSE WK1    12406   3-20-91   7:38a
_STAT    WK1     5444   3-20-91   7:38a
TF       COM     8170   3-20-91   7:38a
_HOMEBUY WK1     4362   3-20-91   7:38a
_CARLOAN WK1     5232   3-20-91   7:38a
_DAT         <DIR>      4-01-91
123      CNF      376   9-04-92   2:47p
95       COM     2015   7-02-91  12:02p
AUTOEXEC BAT       71   8-10-92   1:23a
BATTERY  COM      128   3-23-92   9:29p
CONFIG   SYS       46   8-10-92   1:02a
       19 File(s)    156672 bytes free

What if we want to see only a few files, or maybe another directory? Or more likely, the listing is so long that much of it scrolls off the screen before we can find what we're looking for. We can add a command line switch or a file name, or even both.

As we said, a special switch character often differentiates command line switches from file names. By conventions set by MS-DOS, switches begin with the slash ("/"), but a few programs require a minus sign ("-") instead. For instance, the /W switch tells the DIR command to do a multi-column listing of file names without file sizes or date stamps:

DIR /W

This form of the DIR command tells MS-DOS to display a wide directory listing. On desk bound PCs, the listing is formatted for 80-columns (or as much as will fit within the display width); DOS 3.22 on our HP 95 formats the list for 40 columns:

COMMAND  COM  CHKDSK   EXE  _CFLOW   WK1
_EXPENSE WK1  _STAT    WK1  TF       COM
_HOMEBUY WK1  _CARLOAN WK1  _DAT
123      CNF  AUTOEXEC BAT  BATTERY  COM
CONFIG   SYS

Since the DIR command assumes that we want to see every file, we frequently enter the command without the *.* path specification (as we just did). This is the same as:

DIR /W *.*

If the file list is still too long for the 16-line display, DIR also recognizes the /P switch to tell it to pause at each screen-full of files. You can use several switches together, though most programs require that a space separates each switch:

DIR /W /P *.*

Note: Don't confuse the forward slash "/" switch character with the back slash "\" used for directory paths.

Wild Cards and Directory Symbols

Say you want to see a list of just HP 95 Memo program TXT files, or a list of only the Lotus spreadsheet files that begin with "JAN." That's the job of MS-DOS wild cards. DOS' wild card characters are place holders, representing zero or more unknown characters. When you specify files using wild cards, MS-DOS will repeat the command for each file that matches the patterns.

The two wild card characters are the question mark ("?") which represents any single character, and the star ("*") representing any number of unknown characters -- or none at all. Here is a summary of the most frequently used DOS symbols and combinations:

MS-DOS Shortcut Symbols

SymbolMeaning
..The previous directory up the tree.
*.*All files in the current directory.
*.All files without an extension.
*Usually means *.*.
?Any single character.
.The current directory.
\The root directory of the current drive.
/Switch prefix.
-Switch prefix (less common).

Notice that this list combines wild cards and directory shortcuts. This is because one can often be substituted for the other.

In DOS, we most frequently use wild cards with COPY, DEL and DIR commands; our examples will use DIR. DIR is always non-destructive, you can experiment with various ways to apply wild cards using DIR without the possibility of damaging or erasing files. These examples should encourage you to follow a consistent file naming strategy, which will make it easier to locate and identify files.

Note: You can use DIR to test wild card names before committing files to history with DEL. Try the file specification first with DIR and watch to make sure the directory listing matches only the files. When you're satisfied with the file listing, type DEL then press F3 to recall the file name from DOS' command template.

The question mark wild card represents any single character at one place in a word. DIR recognizes P?D as PAD, POD, but it could never stand PAT -- it requires an exact match for every character position except where the question mark appears.

DIR P?D

The question mark is again useful when we are looking for several similarly named files, such as a series of daily reports. If you name your spreadsheet files using the date as a number beginning with the year, such as 920804.WK1 for August 4, 1992, you could use wild cards to search for just the August files:

DIR 9208??.WK1

When several characters may match, such as they might above, we often use the star ("*"), which matches zero or more characters. We could rewrite the last example as:

DIR 9208*.WK1

This says to DOS: "Show me all spreadsheet files with names beginning with 9208, and followed by any other characters." However, since the star is a place marker for any number of characters, files found could include 92080000.WK1, and even 9208.WK1 -- as many characters as are allowed to follow, or none.

The star is all-encompassing, every character following the star is ignored. If we're looking for files from any year, but only August, we might be tempted to specify something like:

DIR *08*.WK1

What we would get, though, is a list of all WK1 files. Keep in mind that while we can use any number of question marks, everything following a star -- up to the dot for the file extension -- will be ignored. The star always takes precedence over the question mark.

If the star is too flexible, try using several question marks. When a question mark is the last character in the name, it will match a single character, or none. Continuing with the same naming convention, his example will find the files from any year and any day, for a total of up to six characters, but it will also find ??08.WK1 files:

DIR ??08??.WK1

Both MS-DOS wild cards also work with file name extensions, following the same rules and inheriting the same quirks. Star will look for files with any extension, and the question mark represents any single character.

DIR *.EX?

We could say "*.*" with wild cards, a shortcut meaning any file with any extension in the current directory. So to look at all of the files in the current directory we would usually type:

DIR *.*

The shortest-cut of all is just a dot ("."). A single dot is a synonym for the current directory name, without specifying any files. DOS will fill-in the blanks, implicitly adding the "*.*" string, to interpret this shorter version just the same:

DIR .

DOS is a Disk Operating System -- there are lots more disk commands like DIR. Here's a look at interesting uses for some of these commands.

Some More File Commands

CommandNotes
CD _SYSChange to a different directory.
CD .. Change to the next directory up in the tree.
CHDIR _SYSSynonym for CD.
COPY a bCopy a file from one place to another. You can specify a path only or a path and new file name for the destination.
DEL _SYSWhen used with a directory name, deletes all files in the directory. With a file name, it deletes all matching files.
DEL .Works like DEL *.*
ERASE _SYSSynonym for DEL.
RD _SYSShort for "Remove Directory." Deletes empty directories
REN a bRename a file or group of files. Cannot be used to rename directories.

Note: If you've used programming language like HP BASIC, DOS commands may seem strange looking. There are no strings in MS-DOS, so it isn't necessary to put file names in quotation marks. Second, there is no TO keyword in the COPY command; just type two file names separated by a space.

Two useful internal commands are TIME and DATE. The HP 95 Setup program has menu entries for setting the time and date, but many people prefer to set the time in DOS, since the format is simpler and you can leave out the seconds or add everything down to the hundredth for absolute accuracy (or we can pretend that it's absolutely accurate). Simply type the command name at the DOS prompt:

TIME

DOS will show the current time and ask you to enter the new time:

Current time is  14:02:28.00
Enter new time:

You can type the time in 24-hour format, separating the fields as in the example. When you press ENTER, DOS will set the internal clock. If you change your mind and decide not to set the time, press CTRL+C. The DATE command works exactly the same.

Caution: DOS commands are so short and simple that it's just as easy to do damage as good. Be careful about COPY and DEL, especially with wild cards. Once a file is deleted or overwritten, it's gone forever.

In Filer, the Goto command makes changing to another directory or disk drive, or even viewing a file a simple fill-in-the-blanks affair. DOS is just as easy, but there are a few things to keep in mind, as we've seen. TYPE replaces the file viewer, CD changes directories, and to change to a different disk drive we just type the drive letter:

C:

Note: If you try to change to a bad drive letter (say, A:, when there isn't a card), Lotus 1-2-3 won't stop you. From then on, you are stuck with the bad letter and must exit from the program to straighten things up.

DWIM: Do What I Mean

DOS commands like DIR expect all sorts of vague path and file names. DOS will put up with a lot of typing abuse. The process is known as Do what I mean, or DWIM for short. If you leave out a name or a few characters, MS-DOS will still try to make sense of it. You can enter commands and path names in several strange ways, and commands -- actually DOS' command processor -- will figure out what you mean.

The file specification in the command above could also be written as ".\*.*" because DOS automatically fills-in the missing file name. In fact, we can take further advantage of the intelligence of DIR by not specifying anything:

DIR

DOS will assume we mean the current directory, so it will fill-in the missing star-dot-star. Two dots means the next directory out of the tree. We can see a list of all of those files with "..\*.*" or even the shortcut version, and let DOS fill-in the missing file name:

DIR ..

Internally, MS-DOS always expands file name. It converts every character to upper case, then it replaces stars with question marks until the file name fits into this template:

????????.???

After expanding the name, DOS makes the comparison by expanding disk file names into the same template. If you specify "*.TXT" MS-DOS will expand the template to:

????????.TXT

The disk file, perhaps README.TXT, is coerced into:

README??.TXT

Following the question mark wild card rule, we have a winner. These file names match. When DOS displays the file name, it replaces the question marks with spaces.

The Trouble With Arguments

In its infancy in the early '80s, MS-DOS didn't recognize disk directories, or for that matter any kind of storage beyond floppy disks. The forward slash, commonly used (then and now) by other operating systems to delimit directory names, wasn't needed. So DOS programs used it for the command line switch character (even though the minus "-" was already in common use at the time). When MS-DOS matured, lo and behold the forward slash was already taken, so the backslash became the directory name delimiter.

Today, MS-DOS internal commands and utility programs follow the slash-convention. Some programs -- throwbacks or programs imported from the UNIX operating system -- still require the minus. To further confuse things, DOS allows the minus in file names. In attempts to appease everybody, some programs recognize both the slash and minus.

Note: We usually enter switches on the line before file names and path specifications. Often this is just a convenience, but many programs will ignore commands that follow file names or -- worse yet -- they will interpret them incorrectly and show error messages and warnings or refuse to work.

Programming utilities usually require the switches before the file specification. DOS external commands aren't as consistent. For instance CHKDSK can accept the file name anywhere, while MIRROR, a command from MS-DOS 5.0 and later, requires the disk drive letter before any switches, otherwise the drive letter will be ignored.

When the command or program expects two file names, remember that the source file comes first, followed by the destination file.

Here are a few hints for avoiding the trouble with arguments:

Pausing and Canceling Commands

When directory listings go scrolling off the top of the screen, you can always execute the command again and hope you see the file you're looking for this time. As we've seen, there's another option: the /W switch, which shows a multi-column listing of just file names. There's yet another solution if the list is still too long, or if you want to see file sizes and date stamps (and for programs and commands that don't recognize the /W stitch.

Three special keystrokes give us more control over how MS-DOS commands work:

KeystrokePurpose
CTRL+SSuspends program display until you press another key.
CTRL+CCancels the program, returns to MS-DOS.
CTRL+BACKBreaks-out-of the program, returns to MS-DOS.

When you've found the information you're looking for, you can press CTRL+C or CTRL+BACK to quit the program. If the program is displaying lots of useful information, more than will fit on the display, you can press CTRL+S to suspend it at each screen-full; the next key you press will continue the program.

Note: While you can follow CTRL+S with any other keystroke to continue the program, try to get in the habit of pressing CTRL+S again to continue. This will make sure that extra, unwanted keystrokes won't be sent to your program or to MS-DOS.

CTRL+S and CTRL+C keystrokes will only work with programs that use MS-DOS for keyboard and display services. This excludes most large, sophisticated programs. Smaller utilities -- like DOS' built-in commands and utility programs such as HP 95 Utility Pack -- usually will support these keystrokes.

One way to spot programs that do not support these services is by observing how the programs work. Programs that recognize unusual keystroke combinations (such as SHIFT+ENTER or CTRL+SPACEBAR) or do formatted, full-screen display, or run in graphics mode, will usually ignore the pause and break keys.

Caution: These keystroke services are provided by MS-DOS, not by the programs. DOS does not inform programs that they have been paused, or that they are about to be involuntarily terminated.

CTRL+C or CTRL+BACK will stop many programs in their tracks. If they are in the middle of performing important tasks (such as copying several files), those tasks will not be completed. Data will not likely be lost because MS-DOS automatically closes all open files when programs exit.

Here a few things to keep in mind about stopping-up the I/O stream:

Missing Commands

The HP 95 has very few external MS-DOS commands. FORMAT, which is an external command in most versions of DOS, is internal on the 95. External command files include CHKDSK.EXE, COMMAND.COM, DEBUG.EXE and SERINT.COM.

ROM-based MS-DOS 3.22 on the HP 95 is missing some commands, and a few commands are different from DOS conventions. FORMAT, for example, can format only RAM cards; therefore it doesn't need any command line switches for disk size.

The most noteworthy absentees are ANSI.SYS, ATTRIB, BACKUP, COMP, DISKCOPY, EDLIN, FC, GRAPHICS, LABEL, GWBASIC, MODE, MORE, RECOVER, RESTORE, SORT, SYS and XCOPY. It's either a glaring oversight or commendable frankness. Surely the latter. The HP 95 gets along quite nicely without most of these programs.

We can be thankful that Hewlett-Packard left-out EDLIN.EXE, the primitive text editor included with (and ignored by users of) each DOS version from 1.0 through 5.0. Along with BACKUP, RECOVER and RESTORE, it's the most justifiably maligned tool in DOS' arsenal.

The SYS command, which copies the start-up files to a boot disk, is not needed by the HP 95, because the start-up files are always available in ROM. Some other utilities, like XCOPY and MODE, aren't needed because of the RAM disks or limited number of display options.

Files and Devices

Most file manipulation is done in programs -- Lotus 1-2-3 creates spreadsheets, Memo edits text files, even HP Calc uses data files for Solver. MS-DOS commands create directories, make back-up copies of files, and prune the overgrown directory tree, but we rarely create files directly in DOS.

File Names

There is nothing to stop you from creating text files in the HP 95's Memo program with COM or EXE extensions. And there's no built-in protection to stop the computer from trying to run a non-program file with a program's name.

MS-DOS File Name Characters

SymbolMeaning
0-9Numbers.
A-ZLetters.
#Number sign.
%Percent sign.*
_Underscore.
&Ampersand.
^Caret.
-Hyphen.*
$Dollar sign.
{ }Curly braces.
~Tilde.
( )Parentheses.*
!Exclamation Point.
@At sign.*

Symbols in this table marked with "*" should be avoided at the beginning of file names because of conflicts with MS-DOS commands and programs.

Note: If you're familiar with HP computers like the 70- and 80-Series, you probably expect file names to begin with a letter, and included only letters and numbers in the names. Also, HP file name extensions are hard coded; the operating system protects us from giving a file the incorrect file type extension. As we've seen, file names are more flexible under MS-DOS. The HP 95 does not have any file type restrictions or protection -- we are responsible to make sure that files have the correct extensions.

Identifying Program Files

MS-DOS takes it on good faith that files named COM or EXE are valid programs. Beyond checking for the EXE file header, there is nothing to identify a program from any other type of file. Nothing good can come of fooling MS-DOS into thinking a file is a program when it isn't. When you're not sure if it's a real program file, there are some ways to check.

Batch files, ending with BAT, are text files containing commands, much as we would enter them from the keyboard, in English-like form. You can list or even edit batch files with the HP 95 Memo program. All DOS commands are allowed in batch files, including a few new commands (which turn batch into a useful language) that we'll talk about later.

Both COM and EXE files are compiled programs, written in a machine-readable language (called, of course, machine language). These files are created from instructions written in programming languages, which are translated to machine language by other programs called compilers.

The COM file type is the oldest MS-DOS program file format. It's an exact image of how the program will look when DOS loads it into memory. COM files are always less than 64K of memory, which is the size of a single code segment. There is nothing in the file to identify it as a valid program to MS-DOS. It takes it on good faith that any program with the COM extension is a valid program (keep this in mind when naming text files).

Note: COM programs frequently begin with a JMP instruction, which is encoded as either E9 hex (a long JMP) or EB hex (a short JMP). You can look at these files with DEBUG, and check for either of these values. The codes translate to 233 and 235 decimal, which are displayed as "ù" and "ú" if you look at the files with the HP 95 Filer program. This is common practice, but it is not a rule; many COM programs do not begin with these characters.

COM program examples in this book, for instance, rarely begin with a JMP instruction. If the program doesn't begin with a JMP instruction, you may still be able to identify it. Try the DEBUG U (Unassemble) command; if it displays a series of valid instructions (not a series of DB or ??? lines), it may still be a program file.

The EXE file is more complex, it can contain multiple segments and various other information. EXE files always begin with a header of at least 512 bytes, so small utilities -- especially for the HP 95 -- are usually written as COM programs. You can identify EXE files by looking at them with Filer: if the first two bytes are "MZ" and just about everything else is unreadable, it's probably an EXE file. The "MZ" isn't program code at all, it's the initials of Mark Zbikowski, one of the developers of MS-DOS. It's not there out of vanity (well, maybe a little bit), but to help identify the file as a valid program.

Caution: If the program extension is EXE but it doesn't begin with the "MZ" signature, MS-DOS won't automatically reject it as an invalid program file. Instead, it will assume that it is a COM program and DOS will try to execute the file anyway.

Devices and Device Drivers

Considering that it's manual-shift, MS-DOS has an automated way of looking at computers. The goal is device independence, so programs can run on any MS-DOS-compatible computer, regardless of how dissimilar the underlying hardware may prove to be. Device drivers are programs -- usually part of the BIOS, called resident devices -- that handle hardware-dependent tasks like video, keyboard and disk drives. Drivers are conduits for programs to communicate with resident devices.

DOS is an expanding universe. The original, idealized MS-DOS world had just these few devices. Millions of computers and billions in development investments later, other installable device drivers control mice (the pointing kind), touch screen panels and infrared ports. These drivers could be supplied by third-parties.

MS-DOS automatically installs several devices when you boot the computer:

MS-DOS Devices

DevicePurpose
COM1The serial and infrared ports.
CONThe console (display and keyboard).
LPT1Line printer, usually a parallel port. Same as COM1 on the HP 95.
NULThe null device (everything is discarded).
PRNThe printer (usually a parallel port, though on the HP 95, the serial port).

In everyday use, we treat devices like files. If you want to print a file, you could send it to the PRN device. This will not create a file named PRN, but it instead passes the information to the device driver with that name:

COPY CONFIG.SYS PRN

The CON device represents the console, both the display and keyboard -- it can both receive and send data. We call the keyboard Standard Input, or StdIn for short. The display is Standard Output, also known as StdOut. Together they are the CON device. These distinctions, and the console device driver, will seem more important and even useful in a few minutes, when we talk about redirection. Using the CON device, we can use COPY like TYPE:

COPY CONFIG.SYS CON

This sends the file to the console, and displays "1 File(s) copied" when it's done. The other side of the console is StdIn; we can create short text files from the keyboard without running any text editor:

COPY CON HELLO.TXT

Now MS-DOS will record your keystrokes in a file named HELLO.TXT. Every time you press ENTER, DOS adds another line to the file. To stop recording text, press F6 or CTRL+Z to enter the end of file character. DOS will again display "1 File(s) copied."

The NUL device is a bit bucket; whatever you throw at it is happily accepted, then just as cheerfully thrown away. Here, the file is copied to the nul device:

COPY COMMAND.COM NUL

The file is copied nowhere, but DOS will also display "1 File(s) copied" when it's done. You can eliminate that message, too, so the computer will do quite a bit of busy work, but the result will be nothing at all being done. Here's a hint about redirection: instead of the console, the message will be redirected to the null device.

COPY COMMAND.COM  NUL > NUL

Here's a trick to keep snoops from bothering your computer while you're away:

COPY CON NUL

DOS looks just fine, accepting keystrokes and displaying text with abandon. MS-DOS will display no error messages, but nothing worthwhile will happen, either. There are three ways get out of this predicament: CTRL+C, CTRL+BACK, or CTRL+Z then ENTER.

Caution: MS-DOS includes a few other standard devices, and some software may add new devices. Unless you're sure what the results of using these devices will be, avoid experimenting. Two MS-DOS devices to avoid are CLOCK$ and AUX.

Taming the RAM Disk

Most of our working files end-up in the C:\_DAT\ directory. Frankly, lots of files we really don't care about land in C:\_DAT\. You can clean-up some of that clutter by deleting unneeded DCF, CTF and PBK files, and even TOPCARD.PCX, that the computer created the first time you booted. You'll find spare copies in the hidden C:\_SYS\ directory. See page 95 for how to use SYSINIT.BAT to restore these files.

This table compares using Filer and the MS-DOS command line to perform similar tasks:

MS-DOS File Commands

If You Want To FilerDOS
Copy a file to a card F2COPY
Rename a file F8REN
Delete a file F3DEL
Copy contents of a directoryF9 to select files, then F2COPY *.*
Create a directory MENU Directory CreateMD
Delete a directory F3RD
Rename a directory F8-

The Filer Rename (F8) function can also rename directories. There is no MS-DOS command to rename directories.

The HP 95 has several permanent files in the C:\ root directory. You can look at them, but you can't change or delete these files. Now say you're an old-hand at Lotus 1-2-3 and you'd like to recover the space taken by the sample WK1 files in the root directory¼ Well, you can't, but don't be concerned about the wasted space because while these files are part of the C: RAM disk, they are in the ROM portion of the drive. The same is true for COMMAND.COM, TF.COM, CHKDSK.EXE and all the files in the C:\_SYS\ directory.

The Filer can only recognize the first 100 files in any directory. Since DOS allocates subdirectory entries on an as-needed basis, reusing deleted directory entries, some new files may be excluded from the Filer list when it exceeds 100 files, even though alphabetically they come before the last entry that made it into the listing.

MS-DOS stores files as units of 512 bytes; 512, 1024, 1536, and so forth. Each file we create, regardless of how small, occupies at least 512 bytes of disk space. Whenever a file grows past a 512 byte boundary, 512 more bytes are allocated to the file.

Other computers and other disk types will use different file storage standards. One of DOS' strengths is its ability to hide these differences from applications programs. From the program's perspective, it doesn't matter if files take 512 bytes or 2K (a common minimum size for hard disk drives).

Redirection and Piping

The device-independence of MS-DOS makes it easy to treat printers and files and displays as much the same thing. The handful of redirection and piping commands adds flexibility to device-independence.

Redirection is usually used with command line utilities and built-in DOS commands like TYPE and COPY.

When a utility asks DOS for input it reads from the console, which is usually the StdIn device. Output is then sent back to the output-half of the console device. The trick of redirection is separating the tasks of input and output from the console, in effect deceiving programs about where information is coming from (or going to). With really complex, convoluted redirection tricks, programs won't whether the data is coming or going. And, MS-DOS is a party to this scheme. O' what tangled webs we weave.

Redirection and Piping Symbols

SymbolPurpose
>Redirects the output to a file or device. If the output is going to a file and the file already exists, the original file is replaced by the new file.
>>Appends the redirected output to a file or device. If the output is a file and the file already exists, the information is appended to the end of the file.
<Use this symbol to read data from a file instead of entering it from the keyboard.
|This is the piping symbol. Use it to redirect output from one program to StdIn of another program. The second program is usually a filter or search program.

These symbols are easier to remember if you visualize them as arrows. The > symbol points data at a device (usually a file). The < symbol points data to a program (usually from a file). The pipe symbol (|) can be interpreted literally: it acts as a conduit, moving information from one device to another.

DOS Console Devices

NameDevice
StdInThe standard input device (usually the keyboard).
StdOutThe standard output device (the display).
StdErrThe standard error device (also the display).

The > Output Redirection Symbol

We often use COPY CON to create small batch files. For single-line files, we can do it even easier. The following example will create the file APNAME.LST, with a single command to assign TigerFox to a key:

ECHO C:\_SYS\TFOX.EXM,1400,TigerFox > C:\_DAT\APNAME.LST

This says to DOS: "Instead of displaying the text, create a file named APNAME.LST, and send the text there."

We often use output redirection to copy a directory listing to a file or the printer using DOS' DIR command. This example sends a directory listing to the printer:

DIR >PRN

If a program or command requires command line arguments, include them on the line before the redirection symbol:

DIR *.WK* > 123FILES.TXT

This says to DOS: "Show me all the Lotus 1-2-3 spreadsheet files, and send the list to the file named 123FILES.TXT."

The >> Output Redirection Symbol

So far, everything we've redirected has the same potential weakness: it could overwrite the contents of an existing file. The DOS designers thought this through thoroughly, adding another symbol, >>, to append the output to an existing file. If the file doesn't exist, >> works just like > to create the file, otherwise the new information is tacked-onto the end of the file.

Using ECHO with output direction is fine for one-line files, but if we later change our mind and want to also include Hearts&Bones, we could start over, or use the append symbol (">>") to add the second line to the file:

ECHO C:\_SYS\TFOX.EXM,1400,TigerFox > C:\_DAT\APNAME.LST
ECHO C:\_SYS\HB.EXM,2300,Hearts&Bones >> C:\_DAT\APNAME.LST

The first line creates the file with the > symbol. The second line, using >> instead of the > symbol, adds another line to the end of the file. If you're distributing commercial software for the HP 95, appending an entry to the end of APNAME.LST with output redirection is a polite, easy way to make keyboard assignments.

Another use for appending output to a file is to create a log of system activity. You could add these three lines to AUTOEXEC.BAT to have the computer automatically maintain a log of the status of the computer each time you reboot:

ECHO Rebooted computer >> C:\_DAT\WORK.LOG
BATTERY >> C:\_DAT\BOOT.LOG
NOW >> C:\_DAT\BOOT.LOG

Each time you run the batch file, these commands will append three lines to the file named WORK.LOG in the C:\_DAT\ directory. The first line is text, the second and third lines are the redirected output from two programs. BATTERY.COM displays the current battery level. NOW.COM displays the current time and date. Instead of displaying the results from these two utility programs, the information is sent to the file.

See also: BATTERY.COM and NOW.COM are included in this book. Page 96 shows how to enter these programs.

The < Redirection Symbol

This symbol is often thought of as the opposite of >. It takes the contents of a file and sends it through a program. The file becomes StdIn. The input redirection symbol is easiest to visualize as similar to TYPE, but instead of displaying the information, you are sending it to another program.

This example says to DOS "Send the contents of the file BATTERY.SCR to DEBUG.EXE:"

C:\_SYS\DEBUG < BATTERY.SCR

Input redirection works only with programs that receive input from StdIn.

See also: Input redirection is often used to enter DEBUG script files. Instead of entering the commands directly in DEBUG, we place them in a text file, then redirect the text file to DEBUG. See page 90 for an introduction to DEBUG.EXE.

The | Piping Redirection Symbol

Piping means to sent the output from one program (or process) to the input of another. This feature is useful primarily with filters like DOS' MORE command, but unfortunately the HP 95 doesn't include any filters.

MS-DOS will run the first program, redirecting the output to a temporary file. After the first program ends, DOS runs the second program, and redirects the contents of the temporary file to StdIn. The second program sees the data as the contents of any stream. Finally, after the second program ends, DOS erases the temporary file.

If you could halt the process midway-through, say around the pipe symbol, then look at the directory, you would find a strangely named file. But when the programs end, that temporary file will be gone. One side effect of piping is that you must have enough disk space available for the temporary file, yet you'll never see the file.

The piping-form of redirection is most useful with filters. The HP 95 doesn't have any filters, so here's the equivalent to the input redirection example above, but re-written using a pipe:

TYPE BATTERY.SCR | C:\_SYS\DEBUG

This says to DOS: "Type the file BATTERY.SCR, but instead of sending it to the display, send it to the StdIn side of DEBUG." There will be a short delay while BATTERY.SCR is copied to the temporary file, then sent on to DEBUG.

Filters read the input stream then modify the information according to how it feels about the data, then it displays whatever is left. For instance, MORE reads and displays a screen-full of information then pauses for a keystroke, then it displays another screen-full, and so forth through the end of the file. Another utility might translate the HP 95's character set to plain-ASCII.

Say you have a program that needs a single character input, but it doesn't read the command line. You could run the program then press the key at the prompt; a bother if you use the program often, and always with the same keystrokes. Fortunately, there aren't many programs this dim-witted anymore. One that remains is a public domain hard disk head parker called SHIPDISK.EXE. This example echoes the number 1 (for the first hard disk) and pipes it through SHIPDISK:

ECHO 1 | SHIPDISK

Caution: Always keep in mind the difference between the output redirection and piping functions. If you accidentally redirect information to a program instead of piping it through the program, you will overwrite the program file with the output data. For instance, say you want to list a long text file and you are using a utility named MORE to split-up the file into screen-size bytes. The correct command line will look like:

TYPE MYFILE.TXT | MORE.COM

If you accidentally used the > symbol, as in:

TYPE MYFILE.TXT > MORE.COM

you would overwrite MORE.COM with the contents of MYFILE.TXT. To lessen the chance of causing any damage with this mistake, enter the program name without the file extension. Then, the worst that can happen is DOS will a create file with the same base-name as the program.

Caution: Be careful with piping with program that expect and accept only a limited number of options. When input is redirected and there is nothing left to read, the keyboard is inactive and the program cannot ask for information. For example, the following will send the incorrect information to the TIME command, and since TIME expects redirected input, it will ignore the keyboard:

ECHO ? | TIME

The solution is to press CTRL+BACK (the break key) when the computer gets stuck. Even CTRL+C won't work here, so that's the only solution. Many programs disable the break key; avoid using redirection with those programs if you cannot be assured that they'll get the right information sent to them.

Top | Notice | Home | | © Copyright 2007 R. E. Harvey, All rights reserved.