Input Statement
Receives input data from the display device and stored in a variable(s).
Syntax
Input varName [ , varName, varName,... ]
Parameters
- varName
- Specify the variable name. Multiple variables can be used with the Input command as long as they are separated by commas.
Description
Input receives data from the display device and assigns the data to the variable(s) used with the Input instruction.
When executing the Input instruction, a “?” prompt appears at the display device. After inputting data press the return key (Enter) on the keyboard.
Notes
Rules for Numeric Input
When inputting numeric values and non-numeric data is found in the input other than the delimiter (comma), the Input instruction discards the non-numeric data and all data following that non-numeric data.
Rules for String Input
When inputting strings, numeric and alpha characters are permitted as data.
Other Rules for the Input Instruction
- When more than one variable is specified in the instruction, the numeric data input intended for each variable has to be separated by a comma (",") character.
- Numeric variable names and string variable names are allowed. However, the input data type must match the variable type.
Potential Error
Number of variables and input data differ
For multiple variables, the number of input data must match the number of Input variable names. When the number of the variables specified in the instruction is different from the number of numeric data received from the keyboard, an Error 2505 will occur.
See Also
Input #, Line Input, Line Input #, Print, String
Input Statement Example
This is a simple program example using Input statement.
Function InputNumbers
Integer A, B, C
Print "Please enter 1 number"
Input A
Print "Please enter 2 numbers separated by a comma"
Input B, C
Print "A = ", A
Print "B = ", B, "C = ", C
Fend
A sample session of the above program running is shown below: (Use the Run menu or F5 key to start the program)
Please enter 1 number
?-10000
Please enter 2 numbers separated by a comma
?25.1, -10000
A = -10000
B = 25 C = -10000