Colon (:) Tokens

Updated June 2022; see History

Certain special commands or tokens begin with the colon, which may be in the first column or which can be indented.

Command

Meaning

:< .... >

outputs the text between the opening and closing angle brackets; may span multiple lines. This is the normal way to print operational messages on the screen from within command files.

:T
(trace)

causes all commands from that point forward to be traced—i.e., be displayed on the screen. This is very useful for debugging, but may be too verbose for normal use.

:R
(respond)

causes just the output of commands to be displayed; the commands themselves do not display. This produces a somewhat cleaner looking result.

:S
(silence)

silences all output. Unfortunately, this is the default, if neither :t or :r are supplied first.

:X (exit)

causes the CMD or DO file to exit. This is equivalent to the EXIT command.




:K
 (keyboard)

stops and waits for keyboard input. The input is then processed by whatever process is currently in effect (i.e. either a program or the command line processor itself). For example:

SET CTRLC
:<This command erases all files!!!
Hit ENTER to proceed or ^C to abort: >
:K           ; ^C will abort here; ENTER will just proceed
ERASE *.*



:P
(partial)

may be used in conjunction with :k to append the keyboard input to a partial command line. For example:

:R
:<Enter name of file to display: >
:P
EZTYP
:K

 

K0 - K9 Tokens

The command file processor supports a variation of the :K token to input keyboard responses into variables which can tested in IF statements and used as DO file parameters. The following sample file provides an example:

:R

:<Enter desired ppn: >

:K0

 

:S

:<Enter password: >

:K9

IF "$KBD9" = "SECRET"

DOLOG $KBD0

 

The special token :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 command 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 (just IF and DO) to interpret them.

History

June 2022: A-Shell 6.5.1715, DO.LIT 2.1(126):  support indentation of the colon directives as illustrated in the example MAIN.DO; previously they had to be in column 1.

December 2004, A-Shell 4.9.909:  Function added to A-Shell