|Liberty BASIC Help Online
INPUT$( #h, n )
This permits the retrieval of a specified number of items from an open file or device using #handle. If #handle does not refer to an open file or device then an error will be reported. It can also be used to read a character at a time from the mainwindow (see example below).
'read and display a file one character at a time
open "c:\autoexec.bat" for input as #1
if eof(#1) <> 0 then [quit]
print input$(#1, 1);
For most devices (unlike disk files), one item does not refer a single character, but INPUT$( ) may return items more than one character in length. In most cases, use of INPUT #handle, varName works just as well or better for reading devices.
Here is another example which shows reading keypresses in the mainwindow.
'accept characters and display them until Enter is pressed
text$ = ""
while c$ <> chr$(13)
c$ = input$(1)
if c$ <> chr$(13) then text$ = text$ + c$
print "You typed:"; text$
File input directly to an array.
Previous versions of Liberty BSIC required you to input to a variable, then filll an array with the variable. Liberty BASIC 3 removes that limitation and allows you to input from a file directly into an array. Example:
'input from a file, directly into an array
open "myfile.txt" for input as #handle
input #handle, array$(total)
for i = 0 to total
Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/