ASK is a program you can use in DOS batch (.BAT) files to ask for user-input.
The input data can then be used within QuickBasic/Qbasic programs (or any
program written in any language that supports reading DOS environment
variables).

ASK does not supply any sort of prompt string.  It just halts and waits for
you to key in your data and then press ENTER.  Any prompt you want can be
displayed via the batch ECHO command before running ASK.  (If you use @ECHO,
the .BAT ECHO instruction itself won't be displayed.)

So, here's how you would use ASK.  ASK inputs a line of data into a text
string and then writes that text string to a temporary batch file,
GETANS.BAT, with the string "SET ANSWER=" prefixed in front of your input
text string.  After running ASK, you would then run the GETANS.BAT program
(within your batch program) via


CALL GETANS


(Don't forget the "CALL" or else your batch program will terminate
prematurely.)  As soon as GETANS returns control to your batch program,
the DOS environment variable ANSWER has been set equal to what you input
to ASK.  (You can delete GETANS.BAT after you call it.  Also, IN BETWEEN
running ASK and calling GETANS, DO NOT change disks or directories.  (Before
running ASK or after calling (and deleting, if you want) GETANS.BAT is a
good place to do that.))  You can now run your QB (or other) program.  If
you're using QB, you can get the "value" of ANSWER via its ENVIRON$ function,
e.g.,


TEXT$ = ENVIRON$("ANSWER")


If you input a numeric value to ASK and you want that numeric value in your
QB program, you can do something like


VALUE = VAL(ENVIRON$("ANSWER"))

(If you aren't using QB/Qbasic, use whatever your language/dialect would use
in place of ENVIRON$ and VAL.)

If there are many different input data that you want to pass to your QB
program, you can run ASK and then GETANS repeatedly.  After each ASK/GETANS
call, you would then (in your batch program) do something like


SET VALUE1=%ANSWER%


or


SET VALUE2=%ANSWER%


and so forth.  When you're all done inputting, run your QB program and use
ENVIRON$ (and VAL if you need it) with all of the DOS variables VALUE1,
VALUE2, etc. (or whatever you named them in your batch program) that you used
ASK and GETANS to define in your batch program.

When you're all done running your QB (or whatever) programs, back in your
batch file--at the end, before terminating, you may want to do things like


SET ANSWER=
SET VALUE1=
SET VALUE2=


and so forth, just so you clear out all of the environment variables that
you no longer need.  (Actually, if you're doing the SET VALUE1=%ANSWER%
thing, you may want to clear ANSWER right after that, and if you aren't
deleting GETANS.BAT after you call it, you might want to delete that at the
end of your batch program too.)

I've added a few more routines like ASK to ASK.ZIP that you can use in DOS
batch files.

PARSESTR inputs a line of text (from its command-line) and splits them into
two parts if those two parts are separated by a space.  (If there's more
than one space, only the first space is counted.  The remaining spaces will
be part of the string returned after the first space.)  It is useful, for
example, if you've just used ASK to input a string of data containing more
than one item.  Let's say you've just run ASK and GETANS, and you've
assigned the result, say "1.53 6.31", to the environment variable VALUE1,
or you otherwise have such an environment variable defined.  You may want
to split out those two numbers and have each one assigned to its own
environment variable.  In your batch file, just do


PARSESTR VALUE1

PARSESTR creates another temporary batch file--GETPARTS.BAT.  After running
PARSESTR, do


CALL GETPARTS


to actually get the parts of your string.  The first part (1.53 in the
above example) is in the environment variable PART1 and the second part
(6.31) is in PART2.  You can again do things like


SET OLDPART1=%PART1%


and


SET OLDPART2=%PART2%


if you want to save this data so you can use PARSESTR over again for
something else.  (Like GETANS.BAT and the other temporary batch files
associated with other routines to be discussed below, you can delete
GETPARTS.BAT after you call it.)  Also, if PART2 still contains spaces
that separate other items that you want to break out of the string, you
can apply PARSESTR (and then GETPARTS) again to it...and so on, depending
on how many spaces your initial string contained.

Let's say you have a text file containing M lines of text and you want a
batch file you're running to retrieve line N from that file and store it
in an environment variable.  You can use GETLINE to do that.  The syntax
is


GETLINE FILENAME N


where FILENAME is just the name of the file you want to read a line of
data from.  GETLINE creates the temporary file OUTLINE.BAT.  You would
call that batch file via


CALL OUTLINE


to actually create the environment variable storing your line of text.
That environment variable is LINE.  As usual, you can do things like


SET OLDLINE=%LINE%


if you want to save that data so subsequent uses of GETLINE and OUTLINE
don't overwrite it.  (If N is less than one, LINE will be the first line
in the file you're reading.  If N > M, LINE will be the string "^Z".  You
can use this to test for an end-of-file condition, but it eliminates the
ability to actually read a line of text consisting soley of that from a
file (unless it's at the end), for whatever reason you might want to do
that.

ARITH is a somewhat archane utility, but I found it useful, so you might
too.  You can use it to do (long) integer arithmetic.  The syntax mimics
the standard algebraic syntax:


ARITH #1 OPERATOR #2


where "OPERATER" is "+", "-", "*", "/" or "\" (without the quotes).  "\"
is a common symbol for "integer divide."  It will be used internally by
ARITH even if you use "/".  So, as far as you're concerned here, "\" and
"/" are the same thing.  I only allowed for use of the backslash for people
who might use it reflexively.)  It may be obvious, but #1 and #2 are the
numbers you want to use.  For division, the result is #1 divided by #2, and
for subtraction, it's #1 - #2,  As usual, ARITH doesn't actually create a
result you can immediately use.  It again generates another temporary batch
file--RESULT.BAT  After running ARITH, run RESULT.BAT via


CALL RESULT


You arithmetic value will be stored in the string represented by the
environment variable RESULT.  (As usual, you can bracket it with % signs
on the right of an equal sign to save it in some other environment
variable.)

UCASE converts a string to upper case.  It's used via


UCASE string


where string is the character string you want to convert, and then you do


CALL UPPER


to set the environment variable UPPER.  UPPER contains your converted
string.

RPLS replaces all occurrences of substring sub1 in string with the
substring sub2:


RPLS string sub1 sub2


If sub2 isn't specified, RPLS will take sub2 to be a space.  If you want
sub1 to be a space character, type "".  This means that you can't use RPLS
to replace two double quotes that appear next to each other in a string;
sorry about that.  You then do


CALL NEWSTR


to set the NEWSTR environment variable, which contains your new string.

As with the ANSWER environment variable created by ASK's GETANS.BAT, you
may want to clear the environment variables created by the other batch
files mentioned above (as well as any other variables you saved them in)
before your batch program ends--and you can also delete the .BAT files
created by the various utilities.
