INPUT Statement with the ELSE Clause

The INPUT statement is used to request input data from the user’s terminal. If stacked input is present, the next line of stacked data is used instead of requesting data from the terminal.

Format

INPUT var {,int.exp}{:}{_}{THEN/ELSE}{ON TIMEOUT}

Description

The ELSE clause is taken if the terminal’s time waiting for input has expired.

NOTE

The optional THEN/ELSE clause is only supported if the SET-INPUT-ELSE system switch has been set to ON (default is OFF). The THEN/ELSE clause may cause syntactic ambiguities and should be used with caution. Use of the optional ON TIMEOUT clause is the preferred format since it functions the same way as the ELSE clause and does not cause ambiguity in format. The ON TIMEOUT clause is taken when the time out value specified by the last TIMEOUT statement has elapsed.

The maximum input length allowed is 140 characters. The user may specify fewer characters using the optional int.exp clause, but not more. If the maximum number of characters is entered, an automatic ENTER is executed unless the underscore (_) option is present. If the optional underscore is present, the user must physically press ENTER. A bell character is echoed to the terminal if the user attempts to enter more than the maximum number of characters before pressing ENTER.

If the optional colon (:) is used, the ENTER is inhibited on the screen and the cursor remains positioned after the input data.

The statement INPUT A causes a prompt character to be printed at the terminal. The data input, or a null string if only ENTER is pressed, becomes the current value of variable A.

The INPUT statement treats an input length of 0 as a special case. It returns the next character from the input buffer without any editing taking place before the return. For example, if the letter A is typed, followed by a backspace and the letter B, the user gets each of those characters in turn, not just the letter B. This feature is very useful if the user wishes to allow users to use function keys or even the ESCAPE key in customized input routines.

See Also

Statement and Function Reference