INPUT statement 

Purpose

Read a line from the keyboard, assigning data to one or more variables.

Syntax

INPUT [prompt,] variable_list

Remarks

prompt is a string literal or equate that is displayed to the user as a prompt.  variable_list is a comma-delimited sequence of one or more string or numeric variables.  Leading spaces ($SPC) are removed from string data.

If a single INPUT statement prompts for more than one variable, the user must enter the proper number of values on a single line, separated by commas.  If not enough comma-delimited values are entered, remaining variables are set to zero (if numeric) or empty (if string).

Restrictions

INPUT supports fixed-length and ASCIIZ string variables; input data will be truncated as necessary to fit into such strings.  Dynamic strings receive the data without truncation.  UDT variables may not be used, although fixed-length and ASCIIZ UDT member variables are supported.  This statement always returns keyboard input.  It is not subject to input redirection.

See also

INKEY$, INSHIFT, INSTAT, INPUT#, LINE INPUT, WAITKEY$

Example

StartHere:

CLS

  PRINT "Please input your name, then type a comma,"

  INPUT "and state your age, using digits: ", var1$, var2&

  CLS

  IF LEN(var1$) = 0 THEN  ' no name given

    PRINT "You need to input your name."

  ELSEIF var2& = 0 THEN   ' no age given, or missing comma

    PRINT "Hi "; var1$

    PRINT "Please input your name, a comma, and age."

  ELSEIF var2& > 51 THEN

    PRINT "Hi "; var1$

    PRINT "Are you really"; var2&; "years young?"

  ELSE

    PRINT "Hi "; var1$

    PRINT "Are you really"; var2&; "years old?"

  END IF

  PRINT "Press Esc to exit, or any other key to repeat."

  IF WAITKEY$ <> $ESC THEN GOTO StartHere ' exit on Esc key