Dec 092017
 
Allows questions & single key answers in batch files.
File BATQUES.ZIP from The Programmer’s Corner in
Category Batch Files
Allows questions & single key answers in batch files.
File Name File Size Zip Size Zip Type
BATQUES.ASM 3086 1387 deflated
BATQUES.COM 36 36 stored
BATQUES.DOC 2256 1004 deflated

Download File BATQUES.ZIP Here

Contents of the BATQUES.DOC file


Bat-Ques
--------

To ask a question:

Bat-Ques tttttt$ where ttttttt is the text of the question

User then keys a single character response.

To check answer, use IF [not] errorlevel cc, where cc is the
character code value of the response. Only single character responses
are supported.

This program allows one to build decently friendly batch files. One
no longer has only the ctrl-break response to a pause (which isn't
very friendly).

Examples:

This program allows a batch file to ask the user a question and
return a one-character response which is testable by the IF
subcommand of bat files, via the errorlevel.

You use the question asker per following example:

.
. (your batch file to ask if user wants to edit with
. mince/emacs or ibm's editor)
.
echo off
bat-ques WHICH EDITOR, m OR e FOR MINCE (EMACS), i FOR IBM's? $
if errorlevel 110 goto badresp
if errorlevel 109 goto minceed
if errorlevel 106 goto badresp
if errorlevel 105 goto ibmed
if errorlevel 102 goto badresp
if errorlevel 101 goto minceed
:badresp
echo Your response was invalid. Sorry.
goto endit
:minceed
if not exist mincomm.sum copy \bin\mince.swp mince.swp
mince %1
if not exist mincomm.sum del mince.swp
goto endit
:ibmed
profed %1
:endit
echo on

Note that the question prompt follows the bat-ques command and must
end with a dollar sign. The ascii value of the response is returned
as the error level. Since error level tests are always greater than
or equal tests, you must check for highest value first and lowest
value last. Example above shows what you do to check for missing
values. Note that the example assumes lower case answers only for
simplicity sake.

Ascii values (e.g., A is 65, B is 66, a is 97) are found in back of
your BASIC manual. Only one character responses are accepted, and
they are not followed by a carriage return.

Extended ascii codes (function and alt keys) should work as per page
G-6 of your BASIC manual; the first call to bat-ques will return a
zero and the next call (presumably "bat-ques $" without another
prompt) will return the number shown on page G-7.




 December 9, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)