The input statement temporarily suspends execution of the program until a response is provided from the keyboard, and then assigns that response to a specified variable.
input {@(col.exp,{row.exp}):} var{= val.exp} {,length.exp} {,fill.exp} {:|mask} {_} {for time.exp{then|else statement.block}}
input {@(col.exp,{row.exp}):} var{= val.exp} {,length.exp} {,fill.exp} {:} {_} {on timeout statement.block}}
: | 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. |
on timeout |
This clause is only available when running in mvBase Compatibility Mode. The timeout value is set up from a prior TIMEOUT statement. When no input occurs for the timeout value specified, the statement block following the on timeout clause is executed. |
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. |
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.
If the input data value is incompatible with the optionally-specified mask expression, the statement prompts again 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 ?.
Some implementations round time.exp to the nearest second.
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.
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.
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$"
Both are valid.
Example A
print @(5,5):"Name: ": input name.new = item<3>, 20 ,"_ " :_ item<3> = name.new
Example B
print @(5,5):"Name: ": input name.new = item<3>, 20 ,"_ " _: item<3> = name.new
This 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 are replaced with spaces (the second character of fill.exp).