Play it again, Sam. (DOSKEY macros and command line retriever) (Column)
by Tony Roberts
One of the highly touted features of DOS 5.0 when it hit the streets a year ago was the macro-handling ability of DOSKEY--DOS 5.0's command line retriever. Now that all the hoopla has died down, DOSKEY's macro function is all but forgotten.
Chances are you've experimented with DOSKEY's macros and quickly moved on to more interesting pursuits. If so, I hope you haven't given up on DOSKEY itself. The program's command line retrieval and editing functions are a substantial power boost for anyone who's not insulated from the command line.
Let's get DOSKEY running and see what it can do. If it's not already installed, enter the command DOSKEY at the prompt. If DOSKEY.COM is on your system's path, it will execute with no problem. If DOSKEY doesn't run, locate the program and execute it by including the entire path in the command line.
DOSKEY's most obvious benefit is that it permits you to repeat and edit previously executed commands without retyping. To do this, you press the up-arrow key or the down-arrow key to cycle through old commands. When you find the one you want to reuse, you simply press Enter to execute it.
The default startup mode for DOSKEY is overstrike. When you edit a previous command, the characters you type replace those already on-screen. If you find it more convenient to edit commands in insert mode, execute DOSKEY again, but this time add the insert switch: DOSKEY/INSERT In either case, you can toggle manually between insert mode and overstrike mode anytime you like by pressing the Insert key. In overstrike mode, the cursor appears as a solid block; in insert mode, the cursor is an underline character.
By default, DOSKEY allocates 512 bytes of memory to hold your command line history. If you use up all that available space, new commands will replace the oldest commands in the buffer.
If 512 bytes isn't the appropriate amount of space for you, change the buffer size as needed, using the bufsize switch. The command DOSKEY /INSERT / BUFSIZE=256, for example, would place DOSKEY in insert mode and would create a 256-byte buffer for the command line history.
There are several shortcuts available for using the command line history. At the outset of any computing session, when only a few commands have been issued, you'll find that scrolling through the history with the up and down arrows is a fast, efficient way to locate and reuse old commands. As the end of the day nears, however, and the buffer is crammed with dozens of old commands, you'll need a faster way.
Use the F8 key to cut through to the commands you need quickly. If you know the command you're looking for starts with the letter p, for instance, enter p on the command line, then press F8 to cycle through only the commands that begin with the letter p. If you can, be more specific. If you want to repeat a copy command you issued earlier, enter COPY on the command line and press F8 to see only the commands that begin with the letters COPY
Although F8 is my favorite DOSKEY shortcut, the F7-F9 combination comes in handy too. Press F7 to see a list of the commands currently held in the buffer. Each command is numbered. Find the number of the command you want to reuse and press F9. DOSKEY will prompt you for a line number. Enter the number for the command you want, and that command will instantly fill the command line and be ready for editing or execution.
Here are a couple of additional DOSKEY tips. To clear the command line, press Esc. If you want to zap the entire command line history and start from scratch, press Alt-F7.
Finally, having DOSKEY installed permits you to enter and execute several commands on a single line. DOSKEY gives you up to 128 characters with which to work, so you can load up your system before you head off to the water cooler.
To use this feature, just enter the commands on a single line, separating them with the Ctrl-T combination. This will appear as a paragraph symbol ([Paragraph]) on your screen. Here's an example:
copy c:\letters\*.doc a: copy d:\123\4qtr*.wk1 b: pkzip archives c: \reports\*.may c:\reports\*.jun
Once you get used to DOSKEY, you'll want it running all the time. The best way to ensure that it's always available is to insert the DOSKEY command and any appropriate switches into your AUTOEXEC.BAT file. The program and a 512-byte buffer occupy just over 4000 bytes. I think the benefits are well worth the small investment in memory space.
Now, if I've offended any of you who really believe that DOSKEY macros are indispensable, good, Drop me a note in care of the magazine or, if you have access to Genie, pop into the COMPUTE RoundTable and take issue with me there. My ID on GEnie is TROBERTS.