HPlogo MPE/iX Commands Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 4  Command Definition F-K

INPUT

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Permits the user to assign a 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] [;READCNT=chars]

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.

chars

The number of characters you want read from $STDIN. If chars is specified as a negative number, INPUT uses the absolute integer value. The maximum allowed (and the default) is the maximum size of a CI variable, which is currently 1024 characters.

Operation Notes

This command allows the user to assign a 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.

CI input redirection can be used to set varname to a record in a file.

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.

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.

  • 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.

INPUT MYVAR <FILEONE

The above example reads the first record in FILEONE into the CI variable named MYVAR. In order to read the entire contents of a file INPUT must be in a WHILE loop and the while loop must have its $STDIN redirected to the file. Eg: READFILE <FILENAME , where READFILE looks like:

 SETVAR EOF FINFO(HPSTDIN, 'EOF')
  WHILE SETVAR (EOF, EOF-1) >=0 DO 
   INPUT MYVAR
    ...
  ENDWHILE

Table 4-2 “INPUT Command Function” illustrates how the INPUT command functions.

Table 4-2 INPUT Command Function

INPUT bleep and the user responds with:What is stored in bleep:Value* of bleep after SETVAR bleep !bleep:
0010011 (integer)
"001""001"001 (string)
TRUETRUETRUE (Boolean)
9+39+312 (integer)
Return(null) or bleep is not modified if it already exists<<error from the parser>>

 

* 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( ) function

Manuals

Using the HP 3000 Series 900: Advanced Skills (31126A Opt. 002)

Feedback to webmaster