FutureBasic Logo

<<    Index    >> FutureBasic 5

input   statement



Syntax:
input ["prompt";]var1 [,var2...]

Description:
This statement displays an optional prompt in the current output window, then waits for the user to enter data from the keyboard. The entered data is displayed in the window (to the right of the prompt, if any) as the user types it. When the user finishes entering the data, the data are assigned to the variables var1, var2 etc., and the program then continues execution at the next statement. This is a simple (but old-fashioned) way to let the user interact with the program.

SpecifierDescription
"prompt";If you specify this parameter, the literal string inside the quotes is displayed as a prompt. The input cursor is displayed just to the right of the prompt.
var1[,var2...]These must be string or numeric variables (not record variables). The data that the user enters are assigned to these variables according to the rules explained below.

Variable Assignment
The input statement expects the user to enter data as a sequence of data items separated by commas or tabs as in this example:
23, green, -15.7
23 [tab] green [tab] -15.7 [cr]

Subsequent text will refer to the more common comma delimiter, but works also with tabs.
Each one of the comma-delimited items is assigned (after some conversion, if necessary) to a separate variable in the var1 [,var2...] list. If the user enters more items than the number of variables in the list, the extra entered items are ignored. If the user enters fewer items than the number of variables in the list, then zeros or null strings are assigned to the extra variables.
The items may undergo some conversion before being assigned to the variables:
Quoted Items
By surrounding an entered item with double quotes, the user can exercise more control over how the item is assigned to a (string) variable. FutureBasic always strips the surrounding quotes from the item before assigning the string to the variable; however:
Therefore, if the user needs to input an item which has leading blanks, or which contains a comma, then he or she should surround the item with double quotes when typing it in. To assign an arbitrary line of entered text to a string variable without the need for enclosing quotes, use the line input statement.

edit field vs. input
input is an old-fashioned way of getting keyboard input. A more appropriate and "Macintosh-like" way to get input is to use the edit field statement.

See Also:
input#; line input; edit field; edit$ function