INPUT [ MPE/iX Commands Reference Manual Volume I ] MPE/iX 5.0 Documentation
MPE/iX Commands Reference Manual Volume I
INPUT
Permits the user to assign a string value interactively to any variable
that could otherwise be set with the SETVAR command. The user may also
create an optional prompt string and have it displayed on $STDLIST before
the value is read. (Native Mode)
Syntax
INPUT [NAME=]varname[;PROMPT=prompt][;WAIT=seconds]
NOTE This command follows the optional MPE/iX command line syntax.
Refer to "Optional Format for MPE/iX Commands" at the beginning of
this chapter.
Parameters
varname Any variable (that can be set with SETVAR) in which
the input string from $STDIN is stored. If varname
does not already exist, INPUT creates it.
prompt The prompt string that is to be displayed on the
standard listing device. If prompt is omitted,
nothing displays, but INPUT then waits for an input
value to store in varname. To include delimiters,
for example, a comma (,) or semicolon (;) as part
of the prompt string, you must surround the entire
prompt string with quotation marks (" or ').
seconds A positive value specifying the number of seconds
for a timed read. If a value is assigned to
seconds, the prompt waits seconds for input and
then terminates the command. The default is zero,
no time limit.
Operation Notes
This command allows the user to assign a string value interactively to a
variable. It also allows the user to create an optional prompt message
that is displayed on the standard list device ($STDLIST) before the value
is read. This command provides a way to establish an interactive dialog
with an executing UDC or command file. If it does not already exist, the
variable varname is always created by INPUT. If you want to delete
varname before ending a session, job, or program, use DELETEVAR varname.
Refer to the DELETEVAR command.
NOTE If a colon (:) is read by the INPUT command at any level other
than the root level CI, the error message END OF FILE ON INPUT.
(CIERR 900) is returned.
INPUT reads a value from the standard input device ($STDIN) and stores it
as a string in the variable named varname. If varname does not exist,
INPUT creates it. If prompt is omitted, nothing is displayed, and INPUT
waits for an input value to store in varname. The variable varname can
be used as you would use any other MPE/iX string variable.
NOTE The INPUT command does not evaluate an expression before assigning
its value to varname. The command recognizes only strings.
Expressions such as 9 + 3 are treated as strings, even though they
are not surrounded by quotation marks (" or ').
The user may optionally specify a timed read by creating a value for
seconds. The pending read prompt is canceled after seconds. The INPUT
command recognizes the HPTIMEOUT variable. The length of the timed read
is seconds or HPTIMEOUT (in minutes), whichever is smaller. If a timed
read (using seconds or HPTIMEOUT) expires, then the pending read
terminates.
* If varname already exists and you enter a null (a Return), then
the value of varname remains unchanged.
* The same thing happens if varname exists and seconds or HPTIMEOUT
expires before a value for varname is entered. In this case,
however, a warning occurs, and CIERROR is set to 9003.
* If varname does not exist and a null (a Return) is entered for the
variable value, then varname is created and set to null ("").
* If varname does not exist and seconds or HPTIMEOUT expires, then
varname is created and set to null (""), and CIERROR is set to
9003.
* If the timed read expires due to the value of the HPTIMEOUT
variable, for example, HPTIMEOUT=1 (in minutes) and the user
executes INPUT bleep,,65, then the session is logged off.
Use
This command is available in a session, job, program, or in BREAK.
Pressing Break aborts the execution of this command, without creating or
modifying varname.
Examples
The INPUT command does not evaluate expressions, it stores them as a
string. For example, the command INPUT bleep accepts and stores input
(somevalue). If you want somevalue treated as an expression and
evaluated and the result assigned to bleep (as opposed to assigning the
string representation of somevalue), use the SETVAR command after using
the INPUT command:
INPUT bleep
SETVAR bleep !bleep
The first command reads whatever value you enter and sets bleep to the
string representation of that input. The second command assigns bleep
the (evaluated) value that you entered.
Table 2-15 illustrates how the INPUT command functions.
Table 2-15. INPUT Command Function
----------------------------------------------------------------------------------------------
| | | |
| INPUT bleep and the user | What is stored in bleep: | Value* of bleep after SETVAR |
| responds with: | | bleep !bleep: |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| 001 | 001 | 1 (integer) |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| "001" | "001" | 001 (string) |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| TRUE | TRUE | TRUE (Boolean) |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| 9+3 | 9+3 | 12 (integer) |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| Return | (null) or bleep is not | <<error from the parser>> |
| | modified if it already | |
| | exists | |
| | | |
----------------------------------------------------------------------------------------------
* The result is an error if the user responds with an unquoted string:
INPUT BLEEP,>
>ABC Return
SETVAR BLEEP !BLEEP
ABC is not a number. And, without quotes around it, ABC is not a string,
either. If ABC is not a defined variable, it has no value to extract.
So, the attempt to evaluate the result of explicitly dereferencing,
!BLEEP produces an error. Refer to the SETVAR command.
Related Information
Commands DELETEVAR, SETVAR, SHOWVAR, INPUT ( ), EVAL function
Manuals Using the 900 Series HP 3000: Advanced Skills (31126A Opt.
002)
MPE/iX 5.0 Documentation