Thanks, actually I did that about 1/2 hour after posting.
Seems to work ok. There is also a poke to turn off the onerr.
poke 216,0
Thanks!
Derek Peschel wrote:
On Sat, Dec 15, 2001 at 09:23:34AM -0800, Ron Hudson
wrote:
How can I detect end of file while reading a text
file?
10 print chr$(4)"Open mytextfile"
20 print chr$(4)"read mytextfile"
30 input a$
40 rem process process process
50 if what who how then 30
60 print chr$(4)"close mytextfile"
Try this:
5 onerr goto 60
10 print chr$(4)"open mytextfile"
20 print chr$(4)"read mytextfile"
30 input a$
40 rem process process process
50 goto 30
59 end
60 print chr$(4)"close mytextfile"
99 end
Just assume the EOF isn't there. If it really is, line 30 will generate
a BASIC "END OF DATA" error, which zaps you to line 60. A proper error-
handling routine would check the error type and offending line number
(I have to look up where they're stored).
I assume line 40 gets a line from the file into memory. You obviously
still have to write the code that manipulates the memory copy. The code
to put memory back out to the file is pretty similar to the above.
-- Derek