home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
batutl
/
read131.arc
/
READ.MAN
next >
Wrap
Text File
|
1989-03-27
|
6KB
|
158 lines
▄▄▄▄ ▄ ▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄
█ ▀ █ █ █ █ █ ▀
█ █ █▄▄▄█ █▄▄▄ █▀▄▀█ █ █
█ █▄▄▄ █ █ █ █ █ █ █
█▄▄█ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ █ █ █ █ █▄▄█
┌─────────────────────────────────────────────────────┐
│ │
│ R E A D L N & R E A D K E Y V1.31 │
│ │
└─────────────────────────────────────────────────────┘
Program and Documentation are Copyright 1989 by clySmic software.
All rights reserved.
READLN and READKEY are programs that get input from the keyboard and
place it in environment variables. They're perfect for making
interactive batch files and MUCH easier to use than utilities that use
ERRORLEVEL to communicate the results.
Just put READLN.EXE and READKEY.EXE in a directory on your PATH.
READLN
Usage: READLN "prompt" var
This displays the prompt (which must be in double quotes and CAN
contain >,<, |, or an environment variable) and waits for input. All
input up to an ENTER is placed in the environment variable var. If the
first letter of var is capitalized, so will be the input.
Example 1:
C:\>readln "who are you? " name
who are you? Ralph
C:\>set
NAME=Ralph
...other environment variables...
Example2:
D:\>readln "Enter State Code: " State
Enter State Code: ny
D:\>set
STATE=NY [uppercased because the 1st letter of State was upper]
...other environment variables...
Of course, you would usually use the command in batch files.
READKEY
Usage: READKEY "prompt" var
This displays the prompt (which must be in double quotes and CAN
contain >,<, |, or an environment variable) and waits for input. ONE
character is read (no ENTER is needed) and it is placed in the
environment variable var. If the first letter of var is capitalized,
so will be the input character. If an extended key (function key,
arrow keys, &c.) is pressed, the ASCII representation of the
hexadecimal scan code for the key is placed in the variable. If a
Carriage Return, Escape, BEL, or TAB is pressed, the ASCII
representation of the character's ASCII code is placed in the variable.
Example 1:
E:\>readkey "Your Choice (Y/N): " Choice
Your Choice (Y/N): Y [its uppercased if you press y or Y]
E:\>set
CHOICE=Y
...other environment variables...
Example2:
F:\>readkey "Press or or F5 to exit ... " updown
Press or or F5 to exit ... [F5 was pressed, nothing is seen]
F:\>set
UPDOWN=3F00 [hex representation of F5]
...other environment variables...
PUTTING IT ALL TOGETHER
Here's a batch file example:
@echo off
rem INITIALIZE AND GET USER NAME
set CHOICE=JUNK
readln "Enter and sign in please: " name
:LOOP
rem READ AND PROCESS PROGRAM CHOICE
readkey "Hi %NAME%, F1 =Prog 1; F2 = Prog 2; Esc or X exits " Choice
if %CHOICE%/ == X/ goto END
if %CHOICE%/ == 1B/ goto END
if %CHOICE%/ == 3B00/ goto RUN1
if %CHOICE%/ == 3C00/ goto RUN2
rem ERROR TRAPPING
echo Wrong, Try Again...
goto LOOP
:RUN1
echo Program1
goto END
:RUN2
echo Program2
:END
rem CLEAN UP ENVIRONMENT AND LEAVE
NAME=
CHOICE=
You would replace the ECHOs of program 1 & 2 with the commands to run
these programs. The "/"s in the above example are to avoid syntax
errors in the IF statements if the user presses "=" or ";". The var=
lines remove the variables from the environment. If you leave unneeded
variables lying around, you'll probably fill up your environment.
READLN/READKEY will work with DOS 3.3, 3.31, and 4.00. Results for
other versions of DOS are unknown.
READLN and READKEY are copyrighted by clySmic software, and is released
as "Freeware".
You may copy the program and distribute it without charge. You may not
sell or otherwise charge for READLN/READKEY. However, users' groups
may charge a small fee (not to exceed $7) for media and postage.
These programs are provided AS IS without any warranty, expressed or
implied, including but not limited to fitness for a particular purpose.
So there.
clySmic software is not responsible for anything that may happen when
you use READLN/READKEY, including hardware damage, information loss, or
baldness.
Donations cheerfully accepted.
READLN and READKEY were written in Turbo Pascal with Turbo Professional
and TPEnv.
Ralph B Smith Jr
clySmic software
P. O. Box 2271
Empire State Plaza
Albany, NY 12220