Detecting End-of-File using READLINE command
John Esak
john at valar.com
Mon Sep 13 20:02:44 PDT 2004
> -----Original Message-----
> From: filepro-list-bounces+john=valar.com at lists.celestial.com
> [mailto:filepro-list-bounces+john=valar.com at lists.celestial.com]On
> Behalf Of Bob Stockler
> Sent: Monday, September 13, 2004 10:42 PM
> To: filePro mailing list
> Subject: Re: Detecting End-of-File using READLINE command
>
>
> On Mon, Sep 13, 2004 at 12:08:29PM -0400, John Hemmer wrote:
> |
> | When using the READLINE command to read sequential records
> | e.g.
> |
> | bytes=READLINE(handle,destination,length)
> |
> | When a line consists of just a newline character, the number of
> | bytes read and returned in "bytes" may be zero. However, there
> | could be many records that follow this line.
> |
> | How can I detect the EOF, End-of-File? Is a negative number
> | of bytes returned?
> |
> | None of the Documentation I have, STN Manual, Online FilePro
> | help, etc, answers these questions.
>
> A GOOD REASON to get Laura's Help Files. Exerpt:
>
> v4.5 n = TELL(handle) - Returns the current position in the file.
>
> Example:
>
> then: declare local handle(8,.0)
> then: handle = open("/tmp/myfile.dat","rwt")
> if: handle lt "1"
> then: end
> then: cnt = filesize(handle)
> loop if:
> then: cnt1 = readline(handle,buffer,"256")
> then: ' do something with "buffer"
> if: TELL(handle) lt cnt
> then: goto loop
>
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...
John
More information about the Filepro-list
mailing list