home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
sysutl
/
setpgms.arc
/
SETREAD.DOC
< prev
Wrap
Text File
|
1986-12-20
|
4KB
|
107 lines
SETREAD - Use to restore the current directory
Requires DOS 2.0 or above and 2048 bytes of disk and memory space (not resident
when not in use).
Copyright 1986, Arnold B. Krueger GPW MI 48236
(ARNY KRUEGER @EXEC-PC 414-964-5160)
Permission for free use and distribution by
interested parties, not for profit, granted.
SETREAD reads the keyboard and places what it reads into the
environment variable READSTR. Usage is:
SETREAD [flags] [name] [flags]
"name" is the name of the environment variable set.
if none is supplied then READSTR is used.
flags are: /U - make input upper case
/L - make input lower case
/F - read letters, numbers and F1-F9 as
if they are function keys (no Cr rq'd)
You can then refer to the named string in .BAT files
using its name delimited by percent signs ('%').
For example:
Echo name of program to run:
SETREAD
echo running: %readstr%
%readstr%
errorlevels set are:
0 if all goes well
1 not at DOS 2.0 or above
2 for environemnt setting errors:
(an error message will be typed)
3 for reading a null string
(no error message or alteration
of the environment will result)
4 for ctrl-break
(no error message or alteration
of the environment will result)
More complex example:
echo off
echo Type in test string
b:setread test %1
if errorlevel 1 goto someerror
echo Read: %test%
goto exit
:someerror
if errorlevel 4 goto ctrlbreak
if errorlevel 3 goto nullread
:envfull
echo environment setting error
goto exit
:ctrlbreak
echo ctrl-break detected
goto exit
:nullread
echo null string read
goto exit
:exit
This example is provided as READTEST.BAT. It is capable of demonstrating all
the features of SETREAD. It is invoked:
TESTREAD [case_flag]
where case_flag is /U, /L, or null depending on the
translation option desired. It prompts for
a string, tests for errors, and types the string
out if there are none.
Design rationales:
The /U and /L options facilitate comparing the read data since
users may type stuff in in either case, and the .BAT language
compares based on case. If you use the /L option, the string
will always be lower, and you can compare using only lower
case comparands.
Null is treated as a special case since variables in the
environment cannot have null contents. If you set them to
null they disappear. Checking the errorlevel allows you
to handle this as a user error, or a deleting of the variable.
Ctrl-Break is treated as a special case to provide a means
for handling them. Usually this is a "Cancel" command.
Future options:
Function key handling
Multiple variables in one read
Substring operations
Notify the author as to what you want