[net.micro.mac] Help wanted with ETHZ Mac Modula-2 Compiler: How do you detect EOF?

paul@oddjob.UUCP (Paul Schinder) (07/28/85)

Since the arrival of the entire ETHZ Modula-2 compiler for the Macintosh,
I've been spending some time learning Modula-2 and playing with the
compiler.  My intent is to do some data analysis on my Mac (finally I can
use the Mac for something other than editing or as a terminal!).  Since the
distributed version doesn't come with an InFile module corresponding to the
OutTerminal/OutFile pair, I decided to try to write a simple module to read
fixed format real numbers from a file on the disk.  As a test, I wrote a
small program which reads a file from the disk and puts it on the screen,
repetitivly using the ReadChar routine in M2Files to read the file.  The
problem is that I can't figure out how to detect the end-of-file.  A loop
like "WHILE NOT EndFile(file) DO ..." results in nothing being read (as,
surprisingly, does WHILE EndFile(file) DO ..., i.e. it's not just a matter
of the wrong result being passed back from EndFile).  If I loop a fixed
number of times, the program works just fine except that it continues trying
to read even after the entire file has been read.  This doesn't cause the
Mac to crash, it's just an annoyance.  If anyone has figured out how to
properly detect EOF (or if someone from ETHZ feels like telling me), I'd
appreciate it.

I'd like to thank ETHZ for making the compiler available to the USENET, and
for the way it was posted (this was the first large posting from Europe that
arrived here intact!).
-- 


				Paul Schinder
				Astronomy and Astrophysics Center
				University of Chicago
				uucp: ..!ihnp4!oddjob!paul
				arpa: oddjob!paul@lbl-csam.arpa