home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
GETKO1.ZIP
/
GETKEY.DOC
next >
Wrap
Text File
|
1990-02-25
|
9KB
|
191 lines
████████████████████████
██ ██
██ GETKEY for OS/2 ██
██ ██
██ Version 1.00 ██
██ ██
████████████████████████
┌─────────────────────────────────────────────────────────────────────────────┐
│ GENERAL │
└─────────────────────────────────────────────────────────────────────────────┘
This program reports a user's keystroke as an ERRORLEVEL for use in batch
file programming. The ERRORLEVEL equals the keystroke's ASCII code. Syntax:
GETKEY lh[..] [B] [C] [D] [E] [F] [H] [R]
where 'l' is the lowest valid keystroke & 'h' is the highest. This string of
low and high values is called the 'mask.' It may have as many character pairs
as needed, in a continuous string without spaces. It must have an even number
of characters. Optional arguments (separated with tabs or spaces) are:
B Beep if the keystroke is invalid.
C Capitalize the keystroke before checking it against the mask. This
option also affects the ERRORLEVEL returned. For example, if the
operator presses 'a' with the C argument in effect, the ERRORLEVEL is
65 (A) instead of 97 (a).
D Ignore ^Break and ^C (the default is to terminate the program)
E Echo the keystroke to the screen. Not needed if you use R. The
default is not to display the key pressed.
F Flush keyboard buffer before getting the keystroke.
H Hide cursor while waiting.
R Make the user press Return to enter the keystroke. Always echoes the
keystroke to the screen.
The program detects only keystrokes reported by OS/2. For example, it
does not recognize Alt-Esc or Ctrl-Esc.
When writing batch files, remember to test for the HIGHEST possible
ERRORLEVEL first. If you test for the lowest possible ERRORLEVEL first, ANY
keystroke will qualify, and the results are unpredictable.
┌─────────────────────────────────────────────────────────────────────────────┐
│ EXAMPLES │
└─────────────────────────────────────────────────────────────────────────────┘
Example 1
To have the user answer a yes-no question, use a sequence like:
GETKEY NNYY C E
IF ERRORLEVEL 89 GOTO YES
:Else answer was NO
These commands let the operator press only a N or Y. The C option capitalizes
the keystroke in case a lower case letter is pressed; thus, a lower case 'y'
would be accepted. If you want alphabetic input (i.e, a letter), we
recommend you always use an upper case mask and the 'C ' option. In this
example, the ERRORLEVEL is set to the ASCII code of the upper case letter (65-
90).
______________________________________________________________________________
Example 2
To have the operator make a numeric menu selection using the Return key
(Enter), use something like this:
GETKEY 04 E B R
This lets the operator press a digit 0 through 4, echoes the keystroke to the
screen, and beeps if any other key was pressed.
______________________________________________________________________________
Example 3
To have the operator make a menu selection with a letter, use something
like:
GETKEY DF C H
lets the operator press a D, E, or F, but doesn't echo it to the screen, and
hides the cursor while waiting. This command will also accept the keystrokes
d, e, or f, since the C argument capitalizes them before checking them against
the "DF" mask.
______________________________________________________________________________
Example 4
Be careful using the C argument. The following does NOT work:
GETKEY ab C
This example would fail because ANY input would be capitalized before checking
against the mask, and no capital letter is going to be valid with a mask of
only lower case letters.
┌─────────────────────────────────────────────────────────────────────────────┐
│ SYSTEM REQUIREMENTS │
└─────────────────────────────────────────────────────────────────────────────┘
This program requires the OS/2 operating system, version 1.0 or later. It
does not require the OS/2 Presentation Manager (PM), though you can run it in
a PM text window.
┌─────────────────────────────────────────────────────────────────────────────┐
│ EXIT CODES │
└─────────────────────────────────────────────────────────────────────────────┘
As stated above, the program's exit code is normally the ASCII code of the
key pressed. However, if an error occurs or the user presses ^C or ^Break (if
they haven't been disabled), the exit code is 255.
┌─────────────────────────────────────────────────────────────────────────────┐
│ REVISION HISTORY │
└─────────────────────────────────────────────────────────────────────────────┘
1.00 Original version
┌─────────────────────────────────────────────────────────────────────────────┐
│ MESSAGES │
└─────────────────────────────────────────────────────────────────────────────┘
This program cannot be run in DOS mode. Either you're in OS/2's DOS
compatibility box, or you're using the MS-DOS or PC-DOS operating system. You
must run this version of GETKEY under the OS/2 operating system, and you
cannot be in the DOS compatibility box.
If the program shows its instructions unexpectedly, there's a syntax error on
the command line. The most common error is a mask with an odd number of
characters, or forgetting to include the mask.
┌─────────────────────────────────────────────────────────────────────────────┐
│ REGISTRATION │
└─────────────────────────────────────────────────────────────────────────────┘
GETKEY was written in C by Richard W. Adams. It is copyright 1990 by the
author, all rights reserved. Portions of the program are copyright Microsoft
Corporation, 1988.
The author provides this copy of the program for evaluation purposes under
the "shareware" concept. You may copy and distribute GETKEY freely if you
meet the following requirements:
■ You include this documentation file with the program
■ You do not modify the program or documentation in any way
■ You charge no fee other than a nominal one to cover distribution costs
■ You do not distribute the program for commercial purposes without the
written permission of the author
You may post GETKEY on an electronic bulletin board or other computer
system for downloading, even if you charge a fee for using the system, as long
as you do not charge a fee specifically for downloading GETKEY. However, you
must include both the executable and documentation files--GETKEY.EXE and
GETKEY.DOC--in a single downloadable file (e.g., a compressed format).
If you use GETKEY for more than 30 days, you must register your copy,
which gives you a perpetual license to use the product. (Bulletin board
operators may leave GETKEY posted on their boards indefinitely, without paying
a registration fee, as long as they comply with the conditions listed above).
To register, send $10.00 to the author at the address below. Not only is
registration a legal requirement under federal copyright law, but registration
fees give shareware authors the incentive to develop new programs and improve
old ones. If you wish to receive a disk with the latest version of GETKEY,
include an additional $5.00 (total of $15.00) with your registration, to cover
shipping and handling. State the version of GETKEY you currently have and
what disk format you need. Site licenses are available for commercial,
government, and other organizations
Finally, this software is provided "as is." There is no warranty,
implicit or otherwise. The author does not guarantee compatibility with your
system, and is not responsible for any damages incurred by use of this
software.
By using this software, you agree to the above terms. Please send any
payments or comments on GETKEY to:
Richard W. Adams
104 Willow Oaks Boulevard
Hampton, VA 23669-1528