home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
keyboard
/
recall.arc
/
RECALL.DOC
< prev
Wrap
Text File
|
1989-10-15
|
37KB
|
772 lines
Command Line RECALL 2.1
Resident Interrupt Handler for DOS Buffered Keyboard Input
(c) Roger Roth
PO Box 840
West Jordan, UT 84084-0840
CompuServ: 70431,2513
No Fee for Use, Not for Sale or Resale
---------------------------------- Contents ---------------------------------
Introduction
- Features
Installation
- Installing on a Hard Disk
- Installing in Memory
Command History
- Buffer 1 vs. Buffer 2
- <UpArrow> and <DownArrow> Keys
- Listing History
- Fetching Old Commands by Number
- Searching for a Command Fragment
Line Editing
- Moving the Cursor
- Deleting Characters
- Toggling Insert Mode
- Two Methods of Backspacing
DOS Compatibility
- Function Keys
- The Template
- Inserting Control Characters
Command Line Options
- Changing Defaults
- Redefining Keys
Aliasing
- Creating Aliases
- Using Aliases
Function Key Macros
- Defining Function Key Macros
- Executing Function Key Macros
Environment Substitution
Environment Completion
Filename and Dirname Completion
Technical Notes
- Calling from Assembly Language
- Calling from C Language
- Internals
- DOS Environment
-------------------------------- Introduction -------------------------------
Command Line RECALL is a Terminate and Stay Resident (TSR) program that
provides recall and full editing of previously entered commands. The user
can move the cursor, insert, and delete, while the entire command line is in
view. When a command is entered, it is saved in a History Buffer so that it
can be recalled at a later time for reuse or revision.
Only part of RECALL.COM becomes memory resident. Much of its executable code
is used to process the many options available after memory install.
RECALL.COM can be executed over and over again without reinstalling itself in
memory.
The following features are supported by Command Line RECALL:
- Retrieve previously entered commands with <UpArrow> and <DownArrow>.
- Display a list of previously entered commands.
- Retrieve previously entered commands by number.
- Retrieve previously entered commands by searching for a string.
- Two separate command line buffers, one for DOS and one for programs that
run under DOS, such as DEBUG and EDLIN.
- Control of memory usage, by specifying the size of both buffers.
- Most options can be set at or after memory install.
- The functions of many keys can be redefined.
- Aliases for frequently used commands.
- Function Key Macros.
- Environment Substitution and Completion.
- Filename and Dirname Completion.
Command Line RECALL tries not to be annoying:
- Close compatibility with regular DOS command line editing.
- Video parameters, including cursor size and display colors, are never
changed.
- Screen sizes other than 25 x 80 are detected and taken advantage of.
- No case sensitivity, all options and Environment Variable strings can be
entered in either upper or lower case.
- An exact match of the previously entered command will not be added to
the History Buffer.
- History Buffers are non-circular. Repeated <UpArrow>s will stop at the
oldest command. Repeated <DownArrow>s will stop at the newest command.
-------------------------------- Installation -------------------------------
To access the many features of Command Line RECALL, it is necessary to copy
RECALL.COM to a subdirectory which is on the PATH. For example, if
RECALL.COM is on a diskette in the A: drive:
C:\> path
PATH=C:\DOS;C:\UTILS;C:\WORDPROC;C:\WRKSHEET
C:\> copy A:\RECALL.COM C:\UTILS
1 File(s) copied
RECALL.COM becomes memory resident the first time it is run. A short message
will be displayed with information about the amount of memory used. To make
Command Line RECALL memory resident:
A> RECALL
Once Command Line RECALL is installed in memory, it will stay in memory until
the computer is reset, <Ctrl-Alt-Del>.
Most users will be happy with the defaults. However, many users will want to
specify various options. For example, to make Command Line RECALL memory
resident, but change some of the defaults:
A> RECALL /SIZE1=2048 /INS+
To make Command Line RECALL memory resident each time the computer boots up,
install RECALL.COM into AUTOEXEC.BAT. Edit the AUTOEXEC.BAT file, and add
one line (with or without options):
RECALL [/options]
------------------------------ Command History ------------------------------
Command Line RECALL maintains two separate History Buffers, one for DOS and
one for programs that run under DOS, such as DEBUG and EDLIN. When working
with one buffer, the other will not be affected. Throughout this document,
the following naming convention is used:
'Buffer 1' is the History Buffer used for DOS command line editing.
'Buffer 2' is the History Buffer used by programs which run under DOS.
The following keys will retrieve previously entered commands:
<UpArrow> edit previous command
<DownArrow> edit next command
<PgUp> edit oldest command
<PgDn> edit most recent command
<Ctrl-PgUp> remove displayed command from History
<Ctrl-PgDn> clear all History
The following commands will display History from Buffer 1:
RECALL display last 20 commands (no parameters)
RECALL /ALL display all commands, pausing every 20
RECALL /ALL /LOG >PRN print all commands, no pause
The following commands will display History from Buffer 2:
RECALL /2 display last 20 commands
RECALL /ALL2 display all commands, pausing every 20
RECALL /ALL2 /LOG >PRN print all commands, no pause
Command Line RECALL actually displays commands (number of screen rows - 5) at
a time. Since most users operate in 25 line mode, this document will claim
that commands are displayed 20 at a time.
By default, the above commands display the command History from most recent
to oldest. The default can be changed, History can be displayed from oldest
to most recent, with a 'RECALL /LIST-' command.
The list commands mentioned above display a number next to each listed
command. A previous command can be retrieved by referencing that number:
RECALL nn recall command #nn
A previous command can be retrieved by doing a non case sensitive search for
a command fragment:
RECALL frag recall previous command containing 'frag'
Ordinarily, when a command is entered, it is added to the History Buffer.
The following are exceptions:
- The command is too short (as specified with a 'RECALL /TOOSHORT1=n'
command).
- The command is an exact copy of the previously entered command.
- The command is a RECALL command with any list option (example:
RECALL /ALL).
- The command is a successful RECALL search command, i.e. a RECALL command
which brings back a previous command for editing.
Once a command is added to the History Buffer, it will stay there until one
of the following events occurs:
- The History Buffer is full and room is needed to add a new command.
Older commands will be discarded to make room for newer commands.
- The command is deleted from the History Buffer with <Ctrl-PgUp>.
- The History Buffer is cleared with <Ctrl-PgDn>.
- The History Buffer is cleared with a 'RECALL /CLEAR' command.
-------------------------------- Line Editing -------------------------------
Command Line RECALL provides the capability for full editing of the command
line with the entire command line visible. Most of the keys described below
have similar use with all DOS programs.
The following keys move the cursor:
<LeftArrow> move left one char
<RightArrow> move right one char
<Ctrl-LeftArrow> move left to beginning of word
<Ctrl-RightArrow> move right to beginning of word
<Home> move to left of line
<End> move to right of line
The following keys delete characters:
<Backspace> delete char to left of cursor
<Ctrl-Backspace> delete char to left of cursor, slide line left
<Del> delete char at cursor
<Shift-Tab> delete word left of cursor
<Ctrl-Home> delete all chars left of cursor
<Ctrl-End> delete all chars at cursor and right of cursor
<Ctrl-Enter> delete all chars at cursor and right of cursor
<Esc> delete entire line
The <Ins> key is used to temporarily toggle insert/overwrite mode. However,
when <Enter> is pressed, Command Line RECALL goes back to its fixed mode
which is normally overwrite. At any time, the fixed mode can be changed to
insert with a 'RECALL /INS+' command or back to overwrite with a 'RECALL
/INS-' command (see Command Line Options in this document).
There are two different methods of backspacing. Both methods delete the
character to the left of the cursor. Both methods work identically in insert
mode or when the cursor is at the end of the line. The difference can be
noticed in overwrite mode when the cursor is somewhere in the middle of the
line. Method 1 will delete the character and replace it with a space.
Method 2 will delete the character and slide the line to the left. By
default, <Backspace> uses method 1 and <Ctrl-Backspace> uses method 2. If
method 2 is preferred, change the definition of the <Backspace> key (see
Defining Keys in this document).
----------------------------- DOS Compatibility -----------------------------
The DOS operating system provides Buffered Keyboard Input, on the DOS command
line and to any program which wants to use it. Command Line RECALL is a new
implementation of Buffered Keyboard Input. <F1> through <F6> will work just
like they used to work with DOS:
<F1> one char from Template to current line
<F2> (+char) chars from Template to current line until char matched
<F3> rest of chars from Template to current line
<F4> (+char) skip in Template until char matched
<F5> copy current line to Template and to History Buffer
<F6> end of file char, <Ctrl-Z> or ascii 26
<RightArrow> works just like <F1>, when cursor is at end of line
To fully understand the DOS compatibility of Command Line RECALL, the
difference between the Template and the History Buffer should be clear. When
a program (DOS, DEBUG, EDLIN, etc.) uses Buffered Keyboard Input, the program
must provide a buffer, the Template, for Buffered Keyboard Input to use. The
Template is the communication link between programs and Buffered Keyboard
Input. Regular DOS command line editing uses only the Template and no
History Buffers. Command Line RECALL maintains its own History Buffers and
normally writes to the Template only when <Enter> is pressed. However, <F1>
through <F6>, and in some cases <RightArrow>, cause Command Line RECALL to
access the Template.
The inserting of control characters into the command line is accomplished
with a trick derived from a similar function of EDLIN, the DOS line editor.
To insert a control character into the command line, press <Ctrl-V>, then one
of the following keys:
key following <Ctrl-V> ascii value inserted into command line
---------------------- --------------------------------------
a through z ascii 1 through 26
A through Z ascii 1 through 26
[ \ ] ^ _ ascii 27, 28, 29, 30, 31
= ascii 127
---------------------------- Command Line Options ---------------------------
Most users will find that Command Line RECALL works just fine with only
default options. This section can be skipped for now and read at a later
time. However, many options are available to customize to a user's needs.
Notice that all options except '/SIZE1=' and '/SIZE2=' can be set after
Command Line RECALL is memory resident.
When Command Line RECALL is run with no options, one of three things can
happen:
1) The first time, it will become memory resident with default options.
2) If disabled (see 'RECALL /OFF' command), it will reenable itself.
3) Otherwise, the last 20 commands will be displayed.
Help:
RECALL /? display short help message
At Memory Install Only:
RECALL /SIZE1=nnnnn size of Buffer 1 (default 512)
RECALL /SIZE2=nnnnn size of Buffer 2 (default 256)
256 <= 'nnnnn' <= 16384
After Memory Install Only:
RECALL /OFF temporarily disable,
use regular DOS command line editing
RECALL /ON enable Command Line RECALL
RECALL /CLEAR clear both command buffers
RECALL /CLEAR1 clear Buffer 1
RECALL /CLEAR2 clear Buffer 2
The '/OFF' option will leave Command Line RECALL resident in memory, but all
'Buffered Keyboard Input' calls will be handled by DOS. The '/ON' option
will reenable Command Line RECALL without using any more memory. The
'/CLEAR' options will throw away all saved command History, but will not
change the size of either History Buffer.
At or After Memory Install:
RECALL /INS- insert mode off, overwrite (default)
RECALL /INS+ insert mode on
RECALL /LIST- list History backwards
RECALL /LIST+ list History forwards (default)
RECALL /ALIAS- disable Aliasing
RECALL /ALIAS+ enable Aliasing (default)
RECALL /ALIASCHR1=c Aliasing char for Buffer 1 (default @)
RECALL /ALIASCHR2=c Aliasing char for Buffer 2 (default #)
RECALL /TOOSHORT1=nn don't save cmds of len <= nn in Buffer 1 (default 0)
RECALL /TOOSHORT2=nn don't save cmds of len <= nn in Buffer 2 (default 3)
RECALL /FILEATTRIB=hh File Completion search attribute (default 00 hex)
RECALL /DIRATTRIB=hh Dir Completion search attribute (default 10 hex)
After Memory Install, Displaying History from Buffer 1:
RECALL display last 20 commands (no parameters)
RECALL /ALL display all commands, pausing every 20
RECALL /ALL /LOG >PRN print all commands (no pause)
After Memory Install, Displaying History from Buffer 2:
RECALL /2 display last 20 commands
RECALL /ALL2 display all commands, pausing every 20
RECALL /ALL2 /LOG >PRN print all commands (no pause)
Redefining Keys:
RECALL /key=function
The possible values for 'key' are listed in the left column below, and the
possible values for 'function' are listed in the second column below. It so
happens that for each 'key' listed below, the default 'function' is listed to
its right. The third column is a short description of the 'function'. By
default, the last 'function' is not assigned to any 'key'. The default
'key's and 'function's are described elsewhere in this document. Upper/lower
case, no difference.
key function description
--- -------- -----------
UP PrevCmd edit previous command in History Buffer
DOWN NextCmd edit next command in History Buffer
LEFT CharL move left one char
RIGHT CharR move right one char
^LEFT WordL move left to beginning of word
^RIGHT WordR move right to beginning of word
HOME BegLine move to left of line
END EndLine move to right of line
^HOME DelLineL delete chars left of cursor
^END DelLineR delete chars at cursor and right of cursor
PGUP FirstCmd edit oldest command
PGDN LastCmd edit most recent command
^PGUP DelCmd remove displayed command from History Buffer
^PGDN ClearHist clear the History Buffer
INS InsMode toggle insert/overwrite mode
DEL DelChar delete char at cursor
F1 FOne F1 function key (DOS compatible)
F2 FTwo F2 function key (DOS compatible)
F3 FThree F3 function key (DOS compatible)
F4 FFour F4 function key (DOS compatible)
F5 FFive F5 function key (DOS compatible)
F6 FSix F6 function key (DOS compatible)
F7 Nothing do nothing
F8 EnvCmpl invoke Environment Completion
F9 DirCmpl invoke Dirname Completion
F10 FilCmpl invoke Filename Completion
BSP BackSpace delete char to left of cursor
^BSP BackSpace2 delete char to left of cursor, slide line left
BKTAB DelWordL delete word to left of cursor
DelWordR delete word at cursor and right of cursor
Example, installing Command Line RECALL in memory with options:
- insert mode on, instead of the default, overwrite
- redefine <Backspace> to use Backspace Method 2
- redefine <Ctrl-Backspace> to Delete Word Left
- Make Buffer 1 larger, 2 kilobytes, instead of the 512 byte default
RECALL /INS+ /BSP=BackSpace2 /^BSP=DelWordL /SIZE1=2048
Example, changing options after Command Line RECALL is memory resident:
- display History backwards
- save only commands 4 characters or longer in Buffer 1
- clear all History in Buffer 2
- disable Clear History function of <Ctrl-PgDn>
RECALL /LIST- /TOOSHORT1=3 /clear2 /^PgDn=nothing
The first example above is valid only on first time use, because of the
'/SIZE1=' option. The second example above is not valid for first time use,
because of the '/CLEAR2' option.
The following examples give a clue as to how Command Line RECALL decides
whether to change options, or to search for a previously entered command, or
to display an error message:
RECALL /INS+ /LisTT-
Command Line RECALL looks for mistakes before it takes any action. The error
will be detected and an error message will be displayed. The default insert
mode will not be changed.
RECALL /LisTT-
Command Line RECALL sees no valid options in this command, so it will assume
that a search for a previous command containing command fragment, '/LISTT-',
is being requested. If there is no matching previous command, a 'No Find'
error message will be displayed.
RECALL 94
Command Line RECALL first looks for command #94. If a 94th command is in the
History Buffer, it will be presented for editing. Otherwise, a search for a
previous command containing command fragment, '94', will be conducted. If
such a command is in the History Buffer, it will be presented for editing.
Otherwise, a 'No Find' error message will be displayed.
---------------------------------- Aliasing ---------------------------------
An Alias is an alternate name. Aliasing allows the user less typing with
frequently used commands. Aliasing can also replace the use of simple one
line Batch Files. An Alias is defined with the DOS SET command. To define
an Alias for use with Buffer 1:
A> set @alias=string
or
A> set @alias="string"
'Alias' is now an alternate name for 'string'. Whenever 'alias' is typed at
the far left of the command line, it will be as though 'string' was really
typed.
Aliasing works only at the far left of the command line. Another feature,
Environment Substitution, described elsewhere in this document, is similar to
Aliasing, but works anywhere on the command line.
Command Line RECALL doesn't care whether or not 'string' is enclosed in
double quotes. However the double quotes allow a user to get certain
characters (namely '<', '>', and '|') into the Environment.
An Alias defined for use in Buffer 1 will have no effect from within a
program which runs under DOS (Buffer 2), and vice versa. The rest of this
section will concentrate on defining Aliases for use from the DOS command
line (Buffer 1). The use of Aliases with Buffer 2 is not as useful, but is
fully supported. To define an Alias for use with Buffer 2:
A> set #alias=string
An '@' before the Alias applies to the DOS command line (Buffer 1). The '@'
can be changed with a 'RECALL /ALIASCHR1=c' command. A '#' before the Alias
applies to programs which run under DOS (Buffer 2). The '#' can be changed
with a 'RECALL /ALIASCHR2=' command.
For example, to make 'D' an Alias for 'DIR':
A> set @d=dir define Alias
A> d use Alias
A> d *.doc use Alias
Aliases are defined with the DOS SET command. The following Alias
definitions are excellent candidates for addition to AUTOEXEC.BAT:
A> set @up="cd .." (quotes optional)
A> set @cmp="echo n| comp" (quotes necessary)
A> set @r=recall
After Aliases have been defined, they can be accessed from the DOS command
line. Column 1 below shows how Aliases are used. Column 2 shows how the
command would have to be typed without the Aliasing feature. For users who
understand DOS Batch Language, column 3 shows an equivalent one line Batch
File. The following examples use the Aliases defined with the above SET
commands:
Aliasing equivalent Batch Language
-------- ---------- --------------
A> up A> cd .. cd ..
A> cmp file1 file2 A> echo n| comp file1 file2 echo n| comp %1 %2
A> r autoexec A> recall autoexec %@r% autoexec
---------------------------- Function Key Macros ----------------------------
Function Key Macros are Aliases. The Function Key Macros feature of Command
Line RECALL is nothing more than a special case of the Aliasing feature.
Function Key Macros can be defined for the following keys:
<Shift-F1> through <Shift-F10>
<Ctrl-F1> through <Ctrl-F10>
<Alt-F1> through <Alt-F10>
Function Key Macros cannot be defined for <F1> through <F10>, as these keys
are used to access other features.
Macros are defined using the DOS SET command, exactly the same way Aliases
are defined. To define Macros for use with Buffer 1:
A> set @macro=string
or
A> set @macro="string"
An Alias is also a Function Key Macro when the Alias, 'macro', is one of the
following (upper/lower case, no difference):
ShiftF1 CtrlF1 AltF1
ShiftF2 CtrlF2 AltF2
ShiftF3 CtrlF3 AltF3
ShiftF4 CtrlF4 AltF4
ShiftF5 CtrlF5 AltF5
ShiftF6 CtrlF6 AltF6
ShiftF7 CtrlF7 AltF7
ShiftF8 CtrlF8 AltF8
ShiftF9 CtrlF9 AltF9
ShiftF10 CtrlF10 AltF10
To define Macros for use with Buffer 2:
A:\> set #macro=string
Thirty Macros can be defined for use with Buffer 1, and thirty Macros can be
defined for use with Buffer 2. Macros defined for use in Buffer 1 will have
no effect in Buffer 2 and vice versa. An '@' before the Macro (Alias)
applies to the DOS command line (Buffer 1). The '@' can be changed with a
'RECALL /ALIASCHR1=' command. A '#' before the Macro (Alias) applies to
programs which run under DOS (Buffer 2). The '#' can be changed with a
'RECALL /ALIASCHR2=' command.
After a Macro has been defined for a function key, pressing that function key
will perform the following actions:
1) Clear the current line (like the <Esc> key).
2) Type in the characters assigned to the Macro.
3) Process the characters (like the <Enter> key).
A caret, '^', has a special meaning in a Macro definition. A '^' as the
first character of 'string' means skip step 1), above. A '^' as the last
character of 'string' means skip step 3), above.
Macros are defined with the DOS SET command. Some examples follow:
A> set @CtrlF6="DIR ^" (quotes optional)
A> set @CtrlF5="set | find "@"" (quotes necessary)
A> set @AltF10=recall
A> set @ShiftF8=^autoexec.bat^
Some examples of using the above defined Macros from the DOS command line
follow:
keystrokes equivalent
---------- ----------
A> <Alt-F10> A> recall<Enter>
A> <Ctrl-F5> A> set | find "@"<Enter>
A> <Ctrl-F6>*.bat A> DIR *.bat
A> edit <Shift-F8> A> edit autoexec.bat
A> altF10 /ins+ <Enter> A> recall /ins+ <Enter>
Notice, in the last example, that a Function Key Macro is being used as an
Alias.
Function Key Macros can be defined on the fly, but those used often should be
added to AUTOEXEC.BAT. Function Key Macros could be very useful in the
implementation of Batch Menus.
-------------------------- Environment Substitution -------------------------
Environment Substitution is similar to Aliasing. An Environment Variable's
equivalent string can be inserted into a command line by proceeding the
Environment Variable with a single quote, ('), or enclosing it between single
quotes. For example:
A> echo The path is 'path' and today is Friday.
The path is C:\DOS;C:\UTILS and today is Friday.
Environment Variables are defined with the DOS SET command:
A> set a=autoexec.bat
A> set @r=recall
Column 1 below shows how Environment Substitution is invoked. Column 2 shows
how the command would have to be typed without Environment Substitution. For
users who understand DOS Batch Language, column 3 shows an equivalent line in
a Batch File. The following examples use the Environment Variables defined
with the above SET commands:
Examples equivalent Batch Language
-------- ---------- --------------
A> type 'a' A> type autoexec.bat A> type %a%
A> r 'a A> recall autoexec.bat A> %@r% %a%
A> echo '@r 'a A> echo recall autoexec.bat A> echo %@r% %a%
Environment Substitution works anywhere on the command line, whereas
Aliasing, described elsewhere in this document, works only at the far left of
the command line.
--------------------------- Environment Completion --------------------------
Environment Completion is similar to Environment Substitution, but allows the
user to edit the Environment Variable equivalent string before pressing
<Enter>. Environment Completion allows a user to edit long Environment
Variable definitions. When <F8> is pressed, the last word on the command
line is looked up in the Environment. If a match is found, an equal sign and
the Environment Variable equivalent string are placed at the end of the line
for further editing.
Without Command Line RECALL, a change to the PATH Environment Variable
requires retyping the whole path. The following example shows how easy
changing the PATH can be:
A> path press <F8>
A> path=C:\DOS;C:\UTILS;C:\EDIT continue editing
---------------------- Filename and Dirname Completion ----------------------
Filename Completion allows a user to type a few characters of a filename,
then press <F10> to complete the filename. <F10> can be pressed again and
again to view other possible completions of the filename. No matter where
the cursor is located, Command Line RECALL uses the last word on the line to
look for a matching file. A blank at the end of the line is just like a
'*.*' at the end of the line.
The following examples demonstrate the use of Filename Completion. The
second column shows how Command Line RECALL searches for matching filenames:
examples what is searched for
-------- --------------------
A> type<F10> TYPE*.* no space before <F10>
A> type <F10> *.* space before <F10>
A> copy \dos\.com<F10> \DOS\*.COM
A> edit a:subdir\<F10> A:SUBDIR\*.*
A> del c:\xyz?.<F10> C:\XYZ?.
A> type J:\xyz*<F10> J:\XYZ*.*
Dirname Completion, <F9>, works just like Filename Completion, <F10>, except
that only subdirectory names are matched. The following example shows how to
use Dirname Completion and Filename Completion to search through a hard disk
directory tree for a file. This particular example searches for a filename
for a COPY command:
keys display
---- -------
copy s C:\> copy s
<F9> C:\> copy STUFF
<F9> C:\> copy SYS
\ C:\> copy SYS\
<F9> C:\> copy SYS\DOS
\c C:\> copy SYS\DOS\c
<F10> C:\> copy SYS\DOS\COMMAND.COM
<F10> C:\> copy SYS\DOS\CHKDSK.COM
------------------------------ Technical Notes ------------------------------
This section is not for everyone. Skip it if seems too complicated or too
boring.
Command Line RECALL is a Terminate-and-Stay-Resident (TSR) program which
traps and completely handles Interrupt 21H, service 0aH, also known as
Buffered Keyboard Input. All other Interrupt 21 calls except 0a are passed
directly to DOS.
Command Line RECALL can be called from programs written in Assembly Language
or in a high level language. When a program calls INT 21 with register
AH=0a, instead of using the old command line editor provided with DOS, the
program now has use of all the editing features explained in this document.
This provides an easy way for a program to get user input. Remember, that
programs that run under DOS use Buffer 2 and use the '#' character for
Aliases and Function Key Macros.
Buffered Keyboard Input can be called from Assembly Language. The following
example is not a complete program, rather Data and Code fragments:
;*** Data ***
TEMPLATE db 81 ;max len of buffered input (incl CR)
db ? ;returned len goes here (not incl CR)
db 81 dup(?) ;returned buffered input chars go here
;*** Code ***
mov dx,offset TEMPLATE ;DS:DX -> Template
mov ah,0aH ;Buffered Keyboard Input
int 21H
mov si,dx ;DS:SI -> Template
mov ch,0 ;CX <- len of user input
mov cl,[si+1]
add si,2 ;DS:SI -> user input characters
The high level language, C, can also be used to access Buffered Keyboard
Input. The following is a complete C program:
/* DOS interrupt with AL and DX arg1,arg2,arg3 -- AH,DX,AL */
extern int bdos(int, unsigned int, unsigned int);
struct template { /* Template for Buffered Keyboard Input */
char max_len; /* maximum return len (incl CR) */
char ret_len; /* len of user input (not incl CR) */
char ret_chars[21]; /* user input characters */
};
main()
{
struct template bfr;
bfr.max_len = 21; /* maximum return len (incl CR) */
printf("Press ^C when Done\n");
while (1) { /* infinite loop */
bdos(10, (unsigned int)&bfr, 0); /* buffered keyboard input */
/* change terminator from CR to NULL, and print results */
*(bfr.ret_chars + (int)bfr.ret_len) = '\0';
printf("\n%s *** Len = %i ***\n", bfr.ret_chars, bfr.ret_len);
/* change terminator back to CR */
*(bfr.ret_chars + (int)bfr.ret_len) = '\r';
}
}
Command Line RECALL was written in a mixture of Assembly Language and C. To
reduce the memory requirements, the part of RECALL.COM that becomes memory
resident was written almost entirely in Assembly Language. C was used to
write the part of RECALL.COM which handles the various command line options.
The memory resident part of Command Line RECALL is executing when the
computer is at the DOS prompt. It is possible that Command Line RECALL will
spend more time executing than all other programs combined. Most of Command
Line RECALL's execution time is spent waiting for user keystrokes.
Command Line RECALL uses INT 21H, Service 8 for keyboard input. This insures
compatibility with DOS piping. In an attempt at maximum compatibility, the
only ascii keystrokes assigned to functions are:
<Enter> ascii 13
<Ctrl-Enter> ascii 10
<BackSpace> ascii 8 redefinable
<Ctrl-BackSpace> ascii 127 redefinable
<Esc> ascii 27
<Tab> ascii 9
<Ctrl-V> ascii 22
To prevent a user from accidentally hosing the DOS pipeline, only two keys
from the above list can be redefined.
Command Line RECALL uses INT 10H, service 0aH for display output. This is a
departure from the more traditional INT 10H, service 0eH.
Command Line RECALL assumes that after it becomes memory resident, the first
program requesting Buffered Keyboard Input is DOS. In this way, calls by DOS
(Buffer 1) can be differentiated from calls by programs that run under DOS
(Buffer 2). If RECALL.COM is memory installed from AUTOEXEC.BAT, and DEBUG
is run after RECALL.COM in AUTOEXEC.BAT, Command Line RECALL will be faked
out and will not behave correctly.
Every program that runs under DOS receives a copy of the DOS Environment.
When Command Line RECALL is run for the first time, it receives a copy of the
DOS Environment. Before Command Line RECALL makes itself memory resident, it
throws away its copy of the DOS Environment and uses COMMAND.COM's
Environment, instead. Therefore, after Command Line RECALL becomes memory
resident, it will notice changes made to the Environment.
When an application is run it receives a copy of the Environment. When a
user Shells out of an application, the DOS Shell will be working with a copy
of a copy of the Environment. Changes made to the Environment when Shelled
out of an application will not be noticed by Command Line RECALL.
The DOS Environment is used heavily by Command Line RECALL's Aliasing and
Macros features. It may be necessary to expand the Environment Size by
including a SHELL statement in CONFIG.SYS, for example:
SHELL = C:\COMMAND.COM /P /E:nnnn
With DOS 3.x and higher, the 'nnnn' is the Environment Size in bytes. To
allocate a 1K Environment:
SHELL = C:\COMMAND.COM /P /E:1024
With DOS 2.x, the 'nnnn' is the Environment Size in 16 byte paragraphs. To
allocate a 1K Environment:
SHELL = C:\COMMAND.COM /P /E:64
On a non-hard disk system with DOS 3.x:
SHELL = A:\COMMAND.COM /P /E:1024
Consult a DOS manual for more details.
---------------------------------- Updates ----------------------------------
To update to the latest version of Command Line RECALL, write:
Roger Roth
Command Line RECALL
PO Box 840
West Jordan, UT 84084-0840
Include $20 (shipping/handling) and mailing label. Specify 5.25" or 3.5".
Diskette will include approximately 15 other utilities, including:
KEYBUF memory resident 160 character keyboard type ahead buffer
KBD keyboard repeat rate, shift bits, stuff type ahead buffer
CLEAR set display rows, columns, colors, cursor in text modes
SEARCH find text strings in ascii files
WTO standard output with escape sequences and optional (Y/N) response
RENN rename files, move files, rename directories with verify