A SERVICE OF

logo

Chapter 4 295
Command Definition F-K
INPUT
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.
CI input redirection can be used to set varname to a record in a file.
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.
•Ifvarname 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.
•Ifvarname does not exist and a null (a
Return) is entered for the variable value, then
varname is created and set to null (““).
•Ifvarname 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