[comp.sys.ibm.pc] An interesting Quiz! : Why do programs eXit rather than Quit on PC's?

pete@octopus.UUCP (Pete Holzmann) (07/24/87)

I've noticed that programs tend to have an eXit command rather than a Quit
command on PC's. I hadn't really thought about it, and implemented Quit for
a screen-based program I just wrote. ALT-<whatever> does everything else,
so ALT-Q Quits from my program.

This is a BAD idea! Why? (answer below)


Well... when you hit an ALT-key, your program gets a two-byte sequence
back: a zero byte followed by a code representing the key you hit.

My program handles this just fine. But it turns out that the MS-DOS shell
(COMMAND.COM) does NOT!

And the key code sequence for ALT-Q just happens to be a zero byte followed
by a byte containing 16 (decimal)... and 16 happens to be CTRL-P ... and
if you accidentally leave your finger on ALT-Q too long, or if it bounces,
then MS-DOS will see a CTRL-P, and connect your keyboard to your printer
(one of those nice undocumented backwards compatibilities from the olden
days of CP/M)... and if there is no printer or if it is turned off, you'll
think your system is totally locked up, just because you left your program!

ARRRRRRRRRRRRRGH! Believe it or not, I actually guessed the answer to this
complaint ("Your program sometimes locks up my computer when I exit") in
only a few minutes. It could have taken a LONG time!

So. NEVER design an MS-DOS program to Quit! :-)

There. I feel better.

-- 
  OOO   __| ___      Peter Holzmann, Octopus Enterprises
 OOOOOOO___/ _______ USPS: 19611 La Mar Court, Cupertino, CA 95014
  OOOOO \___/        UUCP: {hplabs!hpdsd,pyramid}!octopus!pete
___| \_____          Phone: 408/996-7746