Classic Computer Magazine Archive COMPUTE! ISSUE 117 / FEBRUARY 1990 / PAGE 60



Fun WIth Function Keys and Finding Lost Clusters


Tired of typing the same commands over and over again? How would you like to never type CD C: \SCALC5 \ WSHEETS \ 1989 \ NOV \ PERSONAL again? You have the tools to create your own macro keys right on your DOS disk.

The first thing that you'll need to do is make sure your system loads the ANSI driver. From the root directory, type TYPE CONFIG.SYS and then press the Enter key. If you see a line that says DEVICE=ANSLSYS, it means the ANSI driver loads upon power-up. If not, type COPY CONFIG.SYS + CON and press Enter, type DEVICE=ANSLSYS and press Enter, and then press Ctrl-Z and Enter. Make sure that the file ANSLSYS is in the root directory. Finally, reboot your system to load the ANSI driver.

I've used the Edlin editor for this explanation since it comes with MS-DOS and because it allows you to enter the necessary escape codes. Refer to your MS-DOS manual for complete instructions on using Edlin.

You'll need to create a batch file to store your new key definitions. To create the file, type EDLIN filename.BAT.

Let's start by programming the F10 key to produce a directory. At the Edlin * prompt, type II and hit Enter. You should now see 1*. First type ECHO, press the space bar, and then press Control-V followed by two [(open bracket) characters. The next time that you list this line, the V will not be visible, and instead of ˆV[[, you will see ˆ[[. Continuing on the same line, type 0;68;"DIR"; 13p indicating that the F10 key (0;68) will be defined as DIR. The 13 represents a carriage return, the same as hitting Enter. The last character, a lowercase p, denotes the end of the message. The function keys are defined as 0;59 through 0;68 for F1 through F10, respectively. Press Enter and then Control-C. You should be back at the * prompt. Type E and then press Enter to exit Edlin and write the file to disk.

Back at the DOS prompt, type the filename without the BAT extension. Now press F10. If your editing was accurate, the current directory should be displayed.

Be careful, though. If you usually use the F7 key to exit your word processor and you've redefined F7 to print your cat's name, you won't be able to get out. You'll want to create a batch file that restores any of your redefinitions so that programs which use the altered keys can function normally. For instance, to restore F7 to its normal state, you'd type ECHO (Ctrl-V)[[0;65;0;65p in the batch file. The 0 in place of the key definition sets the key back to its original state.

Programs you use often can be run with a single keystroke with this technique. If you run Wordstar from a directory names WS, you can program the F9 key to run the program from any drive or directory by adding this line to your batch file: ECHO (Ctrl-V)[[0;67;"C:";13;"CD C: \WS";13;"WS";l3p.

Try to keep your definitions fairly short. If your definitions exceed 200 characters, they will begin to overlay COMMAND.COM creating undesirable and unpredictable results.

Richard C. Leinecker

Winston-Salem, NC

CHKDSK Rescues Lost Clusters

It's not uncommon to receive this message from DOS:

3 lost clusters found in 1 chains. Convert lost chains to file? (Y/N)

Relax—though confusing, this message doesn't spell disaster.

On a PC or compatible, a cluster consists of two disk sectors. Two sectors are grouped to form a cluster, which is the minimum amount of disk space that the PC uses to store data. Ordinarily, the storage for a file consists of a chain of clusters. In normal usage, files grow and shrink and the clusters become more scattered. DOS keeps track of where these clusters are located so the files are still usable. If you enter the command CHKDSK *.*, DOS prints a list of all the files with clusters found in separate places on the disk. If the file is fragmented, the drive heads will have to travel a lot to read the file.

The easiest way to consolidate a fragmented file is to copy it to another disk.

Occasionally, DOS gets confused and loses track of a cluster. This is the, case with the lost clusters reported by CHKDSK. However you respond to the computer's question, you will still receive the same message the next time you run CHKDSK.

However, if you type CHKDSK/F (for Fix) and answer No to the same question, the lost clusters will be written over and the information they contained will be gone. If you answer Yes, the clusters will be made into files named FILEnnnn.CHK. You can examine these files to see if they contain anything you want to keep.

Tony Roberts

Greensboro, NC