The CMD/DO file processor supports a variation of the :K command to input keyboard responses into variables which can tested in IF statements and used as DO file parameters. The following sample CMD file provides an example:
:R
:<Enter desired ppn: >
:K0
:S
:<Enter password: >
:K9
IF "$KBD9" = "SECRET"
DOLOG $KBD0
The special command :K0 is like :K, in that it waits for a line of input, but instead of passing the input to the current program, it simply stores it as $KBD0. The same concept applies to :K1 thru :K2 ($KBD1 thru $KBD9). The special $KBDn variables may be tested in an IF statement or passed as a command line argument to a DO file.
Note that when using $KBDn in an IF statement, it must be quoted (as in the example above.) However, when using it as a DO file command argument, it should not be quoted. (In the example above, the DO file DOLOG.DO will see the $KBD0 on its command line and convert it to whatever had been entered to the "Enter desired ppn" prompt.)
$KBDn variables cannot be used in any other context, even within a CMD/DO file. Unlike other special $xx variables which can appear in DO files, which are expanded by DO.LIT when it loads the DO file, the $KBD variables cannot be expanded until after the input operation takes place, and thus it is left to individual commands (currently just IF and DO) to interpret them.
This feature requires LIT files of at least the versions shown below:
IF.LIT 1.0(106)
DO.LIT 2.1(121)
MDO.LIT 2.1(121)
History
December 2004, A-Shell 4.9.909: Function added to A-Shell