The input statement temporarily suspends execution of the program until a response is provided from the keyboard and assigns that response to a specified variable.
Syntax
input var{:} input var {=val.exp} {, length.exp} {, fill.exp} {:} {_} {for time.exp {then|else statement.block}} input @(col.exp,{row.exp}){:} var {,length.exp}{mask} {:} |
Parameter(s)
: |
Suppresses the CR/LF after input has been completed. |
=val.exp |
Sets a default value for the input field. This value displays within the input field and the user can 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. |
length.exp |
Specifies 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 ENTER. |
fill.exp |
Specifies 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 spaces 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 this case, the cursor is moved to the end of the input field. fill.exp is ignored if no length.exp is specified. |
_ |
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 pressing ENTER is required for acceptance. Only the number of characters less than or equal to the length expression are accepted. |
for time.exp |
Maximum time that the system waits for input before returning to the FlashBASIC or BASIC program until any of the events below occur:
WARNING—For Windows, this expression is not supported for pib 0 or RPC processes. |
col.exp |
In the input @ form, specifies the screen column address from which the input of data from the terminal is prompted. |
row.exp |
In the input @ form, specifies the screen row address from which the input of data from the terminal is prompted. |
mask |
In the input @ form, mask is used to verify and reformat the actual entry of the data. Any valid format string can 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. If the mask contains a length specification, then length checking is performed. |
Description
col.exp and row.exp must evaluate to valid screen addresses.
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 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 displays as the default at the specified cursor address. Pressing ENTER accepts the default.
A length.exp of 0 is allowed. This syntax is more consistent with other implementations of D3. This suppresses the automatic carriage return after single-character input (that is, holds the cursor position).
If the input data value is incompatible with the optionally-specified mask expression, the statement reprompts for input. mask() functions can be any combination of conversions, pattern-matching operators, or text justification.
When an input statement is executed, a prompt character displays, followed by the cursor. If the @() function is used, the prompt displays preceding the location specified by @(). Unless the prompt character has been changed with the prompt statement, the default prompt character is the ?.
time.exp is represented in tenths of a second, as a positive integer from 1 through 32767. Depending on the implementation, there can be significant restrictions on the admissible values for time.exp.
If time.exp is 0 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.exp is 0 and there is no character waiting in the input buffer, the input statement returns immediately and the else clause is taken.
If time.exp is negative, no time-out 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 when a noncarriage-return terminated input occurs in the allocated time.
NOTE |
On some UNIX implementations, the time.exp, if not null, is rounded up to the nearest second. |
Some implementations round time.exp to the nearest second.
Due to the way UNIX schedules processes, there is no guarantee that, in case of a time-out, the process activates at exactly the specified time. There can be significant differences if the system is heavily loaded.
There are some limitations on the types of numeric expressions used to designate the length.exp. For example, the statement input x,2*3 does not work, whereas the statement input x,(2*3) works.
The input x,0 suppresses the prompt character and allows the input of certain control characters that were previously blocked, such as CTRL+X. Carriage return and linefeed return char(13) and char(10), respectively. CTRL+S and CTRL+Q are used for flow control and return no value unless xonoff is disabled.
Example(s)
answer is the first character entered from the keyboard. No Enter is required.
print ’are you sure? ’: input answer if answer[1,1]=’y’ then goto 100 print ’are you sure? ’: input answer,1: |
input x,0 x = seq(x) |
These two lines perform exactly the same as:
in x |
Using 0 as a length expression is valid.
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$" right justifies, uses two decimal places and puts 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 displays as though the user already typed it in a field of 20 underscores (the first character in fill.exp). As the user edits the data (when backspace is used), underscores replace any erased data. When complete, the user must press ENTER or LINEFEED. The data is then repainted and the underscores disappear and are replaced with spaces (the second character of fill.exp).
See Also