• Please review our updated Terms and Rules here

Read multiple lines from a file in QuickBASIC 7.1

Geez, try something.
Might as well learn now that someone isn't just going to do it for you.
 
Open opens the file.
EOF stands for end of file. It will crash if reading beyond that point.
In general, to read the whole file, you need to wrap Input lines within a Do While Not EOF style structure. Since there are multiple Input functions, you will have to which will work for the task. Some automatically move to the next line or variable; others require the program to update what needs to be read.
That should be enough information to let you find the right sections of the manual.
 
I've now tried the following:

Code:
open "lines.txt" for input as #1
while not eof(1)
line input #1, blah$
wend
close #1
print blah$

It spits just "This is line three" from lines.txt. In lines.txt, there is the following:

"This is line one"
"This is line two"
"This is line three"
 
So what I'm telling it to do is read only the last line of the file?

Someone told me over IRC talking about this same subject that I shouldn't be trying to use QuickBASIC if I don't know how to run it properly.
 
So what I'm telling it to do is read only the last line of the file?
No, you're telling it to read all three, but only print the last one.

Someone told me over IRC talking about this same subject that I shouldn't be trying to use QuickBASIC if I don't know how to run it properly.
Nonsense; how are you going to learn to run it properly if you don't use it. Of course you have to be prepared for some smartass answers if you ask questions here...
 
It's not our place to squash intellectual curiosity. But at this point, you have more than you need to get started and people are dropping not so subtle hints to tell you to get motivated and figure it out.
 
Back
Top