OK all you applesoft experts out there

From: Derek Peschel <dpeschel_at_eskimo.com>
Date: Sat Dec 15 13:33:56 2001

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
Received on Sat Dec 15 2001 - 13:33:56 GMT

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:33:39 BST