Detecting End-of-File using READLINE command
Brian K. White
brian at aljex.com
Mon Sep 13 12:55:55 PDT 2004
Brian K. White wrote:
> What I do is immediately after opening a file I seek to the end and
> store the line number
> then seek back to the beginning
> then proceed with whatever reading I want to do
> and immediately after each read I compare the current line number
> against the stored ending line number.
minor correction: I'm storing and comparing an absolute position in bytes,
not a line number.
the seek command provides an absolute position, which is fine since in this
case neither you nor I really care what line number we're on, we just need
to know if we are at the end or not.
If you wanted to keep track of line numbers you'd have to count them
yourself after any readline, maybe do a loop through the whole file before
your normal loop just to count them if you needed to know the total before
starting the actual work.
Brian K. White -- brian at aljex.com -- http://www.aljex.com/bkw/
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro BBx Linux SCO Prosper/FACTS AutoCAD #callahans Satriani
More information about the Filepro-list
mailing list