Detecting End-of-File using READLINE command

Kenneth Brody kenbrody at bestweb.net
Tue Sep 14 06:31:56 PDT 2004


John Esak wrote:
[...]
> Unfortunately, Bog, the actual filePro files essentially imply (if not say
> explicitly, I don't remember) that using filesize() is not adequate for
> gaining the true filesize of a text file... so the above is not as robust as
> actually using a seek to the end of the file for this purpose...

I assume that you're referring to the note:

    In a text file, it is possible that the value returned by FILESIZE()
    is not the same number of bytes that can be read from the file.

This is talking about counting the number of characters read from a file,
not the size of the file.  In other words, if you were to open a file in
text mode under Windows, and count the number of bytes read from the file
with READ(), it would be less than the value returned by FILESIZE().  This
is because DOS/Windows uses CR+LF as the end-of-line sequence, and this is
returned from READ() as if it were simply LF, so an 80-character line takes
82 characters in the file, but is read as only 81.

However, if you were to READ/READLINE until EOF, the value returned by
TELL() would be the same as FILESIZE(), as TELL() returns the actual
position in the file, not the number of bytes read to that point.

-- 
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody        | www.hvcomputer.com |                             |
| kenbrody/at\spamcop.net | www.fptech.com     | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+




More information about the Filepro-list mailing list