INPUT

INPUT


INMAT Index Level INPUTCLEAR
Syntax INPUT variable{:}

INPUT @(col.exp,{row.exp}){:} variable {,length.expression}{mask} {:}

INPUT variable {=val.expression} {, length.expression} {, fill.expression} {:} {_} {FOR time.expression {THEN | ELSE statement.block}}
Category BASIC
Type Statement
Description temporarily suspends execution of the program until a response is provided from the keyboard and assigns that response to a specified variable.

The "input @" prompts for the input of data from the terminal, at the coordinates specified in the "col.exp" ("column expression") and "row.exp" ("row expression") parameters. Both expressions must evaluate to valid screen addresses. See the "@" function.

The input received is assigned to the specified variable after performing the optional "mask" function. The mask can contain any valid mask described under "masking (BASIC: General)" except for masks beginning with a "c". If the variable already has a value, and the "@" function has been specified, the current value of the variable is displayed as the default at the specified cursor address. A <return> accepts the default.

In the "regular" form of "input", the ":" suppresses the carriage return/line feed after input has been completed.

As of release 7.0, a "val.expression" may be specified to set a default value for the input field.  This value is displayed within the input field and the user may edit this value as need be.  If no editing is performed, then the default value is accepted as if the user had typed that value at the keyboard.

The "length.expression" indicates the number of characters of input to accept. When the number of characters have been entered, the input instruction terminates exactly as though the operator had pressed <return>.

As of release 5.2.3, a "length.expression" of 0 (zero) is allowed. This syntax is more consistent with other implementations of Pick. This suppresses the automatic carriage return after single-character input (i.e. holds the cursor position).

As of release 7.0, a "fill.expression" may be specified to perform a background fill within the input field.  The first character of this expression indicates the prompt background fill character.  This character is used to help the user see the length of a prompt. The second character, if present, indicates the overstrike character used to fill in any blank spots when the input is accepted.  After input is accepted, the cursor is placed at the end of the entered data unless a third fill character is specified in which case the cursor is moved to the end of the input field.  The "fill.expression" is ignored if there is no "length.expression".

If the input data value is incompatible with the optionally-specified  "mask" expression, the statement re-prompts for input.  Mask functions may be any combination of conversions, pattern-matching operators, or text justification. See "masking".

The "_" (underscore) outputs a "beep" to the terminal for each character typed that exceeds the specified maximum length. Echoing of characters to the screen is suppressed for the extra characters and a <return> is required for acceptance. Only the number of characters less than or equal to the "length expression" are accepted. (see warnings).

If "mask" is to be used, the "@" function must also be specified. The mask is used to verify and reformat the actual entry of the data. Any valid format string may be specified. The input is verified against the mask and, if acceptable, is assigned to the variable. Data is input and verified according to the mask, then stripped of its output characteristics and stored in internal format.

For example, if the mask contains a decimal digit specification and/or a scaling factor, then numeric checking is performed; or if the mask contains a length specification, then length checking is performed. See "Format Strings".

When an "input" statement is executed, a prompt character is displayed, followed by the cursor. If the "@" function is used, the prompt is displayed preceding the location specified by "@". Unless the prompt character has been changed with the "prompt" statement, the default prompt character is "?" (question mark).

The "time.expression" is the maximum time that the system waits for input before returning to the FlashBASIC program until any of the following events occur:

1) When a valid termination occurs. The "then" clause is taken.

2) When no carriage return is entered, even though input continues, and no valid termination occurs within the specified time. The "variable" contains all characters entered until the time expired. If no characters are in the type-ahead buffer, "variable" is null. Upon timeout, the "else" clause is taken.

3) When not enough characters are entered to satisfy the "length" requirement within the allocated time, the "else" clause is taken.

The "time.expression" is represented in tenths of a second, as a positive integer from 1 to 32767. Depending on the implementation, there may be significant restrictions on the admissible values for "time.expression". See warnings.

If the "time.expression" is zero and there are characters in the input buffer, these characters are returned immediately when a valid termination criterion is met and the "then" clause is taken.

If "time.expression" is zero and there is no character waiting in the input buffer, the "input" statement returns immediately and the "else" clause is taken.

If "time.expression" is negative, no timeout is in effect.

The "then" clause is taken if valid input is completed within the allocated time. The "else" clause is taken if there is no input, insufficient input, or a non-carriage-return-terminated input occurs in the allocated time.

See the "then/else construct" for an explanation on the use of "then" and "else" clauses in statements that allow or require them.
Options
See Also THEN | ELSE statement.block GET IN INPUTNULL @ function INPUTTRAP ... GOSUB masking PROMPT : statement.block statements & functions u6070 u7070 INPUTCTRL
Example print 'are you sure? ':
input answer
if answer[1,1]='y' then goto 100

print 'are you sure? ':
input answer,1:

"answer" is the first character entered from the keyboard. No <return> is required.

input x,0
x = seq(x)

These two lines perform exactly the same as:

in x

Using 0 (zero) as a length expression is only valid in release 5.2.3 and higher.

input x for 50 else stop

Wait 5 seconds for input. If there is no input, terminated by a carriage return, the program stops.

input x for 0 then print x else x = 0

The time out value equal to 0 means read characters without waiting. If there is any, the 'then' clause is taken, otherwise the 'else' clause is taken.

print "Enter Cost ":
input @(5,5):cost "r2$"

This example uses masking, the above mask "r2$" will right justify, use 2 decimal places and put a '$' on the left of the forced numeric entry.

print @(5,5):"Name: ":
input name.new = item<3>, 20 ,"_ " :_
item<3> = name.new

Displays a prompt for a name on a formatted screen. The data to be edited appears as though the user already typed it in a field of 20 underscores (the first character in fill.expression).  As the user edits the data (when backspace or backword is used), underscores replace any erased data. When done, the user must press <CR> or <LF>.  The data is then repainted, the underscores dissappear and are replaced with spaces (the second character of fill.expression).
Warnings On some Unix implementations, the "time.expression", if not null, is rounded up to the nearest second.

Some implementations will round "time.expression" to the nearest second.

Due to the way Unix schedules processes, there is no guarantee that, in case of a time out, the process will be activated at exactly the specified time. There may be significant differences if the system is heavily loaded.

There are some limitations on the types of numeric expressions used to designate the "length.expression". For example, the statement "input x,2*3" will NOT work, whereas the statement "input x,(2*3)" will work.

The "input x,0" has been changed in release 5.2.5 to suppress the prompt character and to allow the input of certain control characters that were previously blocked, such as <ctrl>+x. In release 5.2.5 and higher, <return> and <line feed> now return char(13) and char(10), respectively, rather than returning null. <ctrl>+s and <ctrl>+q are used for flow control and therefore still return no value.

Note: R83 only accepts the first form of the syntax.
Compatibility D3 7.0 AP 5.2.3 AP R83
INMAT Index Level INPUTCLEAR