|Liberty BASIC Help Online
INPUT #handle "string expression"; variableName
This command has several possible forms:
This form causes a program to stop and wait for user to enter data in the program's mainwin and press the 'Return' key. It will then assign the data entered to var.
input "enter data"; var
This form will display the string "enter data" and then stop and wait for user to enter data in the program's mainwin and press 'Return'. 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
'Display a text file
filedialog "Open..." , "*.txt", filename$
open filename$ for input as #text
if eof(#text) <> 0 then [quit]
input #text, item$
In earlier versions of Liberty BASIC, INPUT could not be used to input data directly into arrays, only into the simpler variables. For Liberty BASIC 3, that limitation no longer exists. It is now possible to use Input and Line Input to fill arrays directly. To input directly to an array:
It is also possible to use this method:
input array$(x), string$, stuff(i)
Most versions of Microsoft BASIC implement INPUT to automatically place a question mark on the display in front of the cursor when the user is prompted for information:
input "Please enter the upper limit"; limit
Please enter the upper limit ? |
Liberty BASIC makes the appearance of a question mark optional.
input "Please enter the upper limit :"; limit
Please enter the upper limit: |
In the simple form input limit, the question mark is inserted automatically, but if a prompt is specified, as in the above example, only the contents of the prompt are displayed, and nothing more. If it is necessary to obtain input without a prompt and without a question mark, then the following will achieve the desired effect:
input ""; limit
Additionally, in most Microsoft 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. Liberty BASIC does not automatically do this, but converts the entry to a zero value and sets the variable accordingly.
The prompt may be expressed as a string variable, as well as a literal string:
prompt$ = "Please enter the upper limit:"