STACK.BAS (with compiled .EXE program included) is a QB program to demonstrate
how to use interrupt 16h to stack keystrokes into the keyboard buffer.  As
currently written, it will only support keystrokes with ascii codes between
32 and 126, i.e., the standard ascii character set.  (But see CSTACK, ASTACK,
FSTACK, NSTACK, and CNSTACK.)  The syntax for using STACK.EXE is

STACK text-string-to-be-sent-to-keyboard-buffer

(For example,

STACK DIR *.DAT

will put a command to show all .DAT files in the current directory on the
screen into the keyboard buffer.)  Normally, a carriage return is also
sent to the buffer at the end of the text you put on the command line.  If
you want to suppress stacking the carriage return, put a semicolon (";")
at the end of your text string.  If you want to actually include a trailing
semicolon in the text to be stacked, use two semicolons (";;") together.
(A carriage return will also be stacked in this instance.)  One constraint
of this program is that you can only stack about 14 or 15 keystrokes before
filling the keyboard buffer.

If you've used previous versions of STACK, you may recall that you had to
gimmick it by pressing the control key while typing letters if you wanted to
stack lowercase letters.  I have removed that necessity by writing a
replacement for COMMAND$.  You can now type lowercase letters as normally as
uppercase ones.

However, there is now a new use for pressing CONTROL-A, CONTROL-B, or
CONTROL-D.  These keypresses on STACK's command line cause, respectively,
the redirection and piping symbols "<", ">", and "|" to be stacked.  (DOS
will not allow explicitly typing these symbols.)

With all of that out of the way, the programs ASTACK and CSTACK are similar.
ASTACK stacks ALTernate keystrokes.  The command line syntax is the same
as with STACK, but only the numerals 0 - 9 and letters A - Z (or a - z)
are relevant.  (The other keys don't have ALTernates.)  For example,

ASTACK B

stacks an ALT-B and

ASTACK fo

stacks an ALT-F and then an ALT-O.  (Carriage returns are not stacked.)
Of course, in order to see any effect of stacking an ALT key, there has
to be some other program taking input from the keyboard buffer as you
put ALT keystrokes into it.  (Nothing shows up on the DOS screen.)  CSTACK
does the same thing for CONTROL keystrokes (only the letters A - Z, or a - z,
apply).  Again, carriage returns are not stacked with CSTACK.

FSTACK stacks keystrokes involving function keys.  Unlike the other programs,
however, FSTACK only stacks one keystroke at a time.  In other words,

FSTACK 7

stacks an F7 keystroke and so does

FSTACK 7 8.

The relevant command line options are the integers 1 to 12.  If an integer
is specified by itself, the normal function key is stacked.  If the integer
is preceded by an "S", the shifted function key is stacked.  Preceed the
integer by an "A" to stack an ALT-function key and a "C" to stack a CONTROL-
function key.  For example,

FSTACK A2

stacks an ALT-F2,

FSTACK c3

stacks a CONTROL-F3,

and

FSTACK S10

stacks a shifted F10.  (No carriage returns are stacked in any case.)

NSTACK stacks keystrokes from the numeric keypad (again, without carriage
returns).  H = Home, U = Up arrow, P = Page Up, L = Left arrow, R = Right
arrow, E = End, D = Down arrow, N = Page Down, and C = Center.  (More than one
keystroke can be included on the command line.)

CNSTACK stacks keystrokes from the numeric keypad as if the control key was
being pressed while the numeric key was being pressed.

There is no shift-keypad program here because there's no need.  You can stack
those keystrokes via STACK--they're the same keystrokes you get with NUMLOCK
turned on or using the normal number keys on the keyboard.  Alternate keystrokes
from the numeric keypad don't appear to exist.

The technique used by STACK/ASTACK/CSTACK/FSTACK/NSTACK/CNSTACK may not work if
you have an IBM XT.  The book that I learned how to do this from said it
requires an AT or better with an "enhanced" (i.e., enyucked) keyboard.  But I
have an AT without such a keyboard and the programs work fine.

In case you want to use these programs in a basic program, via the SHELL
command, to stack data to other DOS programs that you are also executing via the
SHELL command (or, you may be doing this from within a .BAT program), you may
want to clear the contents of the keyboard buffer before stacking data into it.
You can use the program PRGSTK (for "PuRGe STacK") to do this.  (It uses
interrupt 21h and the source code for it is included here too.)

If you should want to modify the .BAS source code for any of these programs
and recompile it, when you go to LINK it, you need to use the "auxiliary
library" QB.LIB.

Glenn Stumpff
(gstumpff@ball.com)
