home *** CD-ROM | disk | FTP | other *** search
-
- INPUT Ver. 1.0
- (c) Copyright 1986
- William C. Parke
- for CHUG
- Capitol Heath Users' Group
-
- INPUT is a batch file utility to get console input from
- within a batch file. There are several variants of this type of
- program in the public domain. A common type uses the ERRORLEVEL
- to pass a keyboard response to a BAT file. These type are
- limited to a single key transfer. Another type, such as ANSWER,
- written by Frank Schweiger, prompts for a console input, then
- puts the result into an Environment Variable. INPUT is of this
- type, but adds some refinement. With INPUT, the response string
- is set to upper case unless the 'bare' switch is used. A
- linefeed is sent to the console after the response to allow a
- following ECHO command. In addition, preceding and trailing
- blanks are removed in the default mode. Another option lets the
- BAT file define the length of the string used in the response.
-
- The syntax for INPUT is the following:
-
- INPUT prompting string [/b/nn]
-
- Output of this program is placed in the Environment Variable
- called ANS. If there is no space left in the Environment, the
- ERRORLEVEL is set to 1. If a previous ANS is found, it is
- removed and the new ANS is placed at the end of the Environment
- Variable list. If there is no response to the INPUT prompt,
- ERRORLEVEL is set to 1. The prompting string may contain any
- standard ASCII characters except the dollar sign and the slash
- '/' character. This string is displayed on the console as soon
- as INPUT is evoked. If no string is present, a help display for
- the use of INPUT is displayed. The brackets above enclose two
- optional parameters. Either or both may be used. They are
- defined as:
-
- b = bare input
-
- nn= a truncation number from 1 to 72
-
- If the 'b' switch is used, then the console response string is
- left as typed and inserted into the Environment as the variable
- ANS. Without the 'b' option, a response string is converted to
- upper case, and any preceding or trailing spaces are removed. If
- the 'nn' truncation number is used, the console response string
- will be truncated to length nn before being used to define ANS.
- This option is useful for insuring that a 'yes-no' answer is
- properly handled. By using 'nn'=1, all of the following
- responses will give an ANS=Y : 'yes', 'y', ' yes', ' y', ' yes ',
- ' y ', 'YES', 'Y', ' YES', ' Y', ' Y ', etc.
-
-
- Example fragments from batch file applications:
-
- Example 1: Getting yes/no answers:
-
- IF EXIST %1 GOTO OK
- INPUT %1 not found. Do you wish to go on? /1
- IF %ANS%==Y GOTO OK
- GOTO EXIT
- :OK
- ...
- :EXIT
- SET ANS=
-
- The last line of this example drops ANS from the Environment,
- saving space for additional variables.
-
- Example 2: Getting new path and file names:
-
- INPUT Give new file name:
- SET FILE=%ANS%
- SET ANS=
- ...
-
- Note: A space should be added at the end of the colon above.
-
- Example 3: Starting a requested program:
-
- ECHO OFF
- :START
- TYPE PROGS.LST
- REM PROGS.LST is an ascii list of programs
- INPUT Enter program and command line, if needed :
- IF ERRORLEVEL=1 GOTO EXIT
- %ANS%
- IF NOT ERRORLEVEL=1 GOTO EXIT
- ECHO Program error.
- ECHO Please re-enter or type a carriage return.
- GOTO START
- :EXIT
- SET ANS=
-
- Note that the user can exit this BAT by typing a carriage return
- in response to the INPUT string. Alternatively, CTRL-C can be
- used for the same purpose.
-
- Comments may be sent to the author via CHUG, Capital Heath Users'
- Group, P.O. Box 16406, Arlington, VA 22215-1406.
-
-
-