Copyright 2008 Shoptalk Systems

INPUT #handle "string expression"; variableName

Description:

This command has several possible forms:

  input var

This form causes a program to stop and wait for user to enter data and press the Enter key or click the Accept button. It will then assign the data entered to var.

  input "enter data"; var

or...

  prompt$ = "enter data"
  input prompt$; var

This form will display the string "enter data" and then stop and wait for user to enter data and press the Enter key or click the Accept button. It will then assign the data entered to var.

  input #name, var

This form will get the next data item from the open file or device using handle named #handle and assign the data to var. If no device or file exists that uses the handle named #handle, then INPUT returns an error.

  input #name, var1, var2

This form causes the next two data items to be fetched and assigned to var1 and var2.

  line input #name, var$

The LINE INPUT statement will read from the file, ignoring commas in the input stream and completing the data item only at the next carriage return or at the end of file. This is useful for reading text with embedded commas

Usage:

  'Display a text file
  filename$ = "readme.txt"
  open filename$ for input as #text

[loop]
  if eof(#text) <> 0 then [quit]
  input #text, item$
  print item$
  goto [loop]

[quit]
  close #text
  print "Done."
  end

Arrays

You can use INPUT and LINE INPUT to fill arrays directly. To input directly to an array:

  input array$(x)

It is also possible to use this method to input more than one thing at a time:

  input array$(x), string$, stuff(i)

Type Coercion

In many BASICs, if INPUT expects a numeric value and a non numeric or string value is entered, the user will be faced with a comment something like 'Redo From Start', and be expected to reenter.  Run BASIC does not do this, but instead will coerce the entry to fit into the variable.

See also: INPUT$(#h, n), INPUTTO$(#h, delim$), LINE INPUT