Detecting End-of-File using READLINE command
Bob Stockler
bob at trebor.iglou.com
Mon Sep 13 19:41:57 PDT 2004
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
A system independent way to read through an entire file.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
See also: CREATE(), OPEN(), READ(), READLINE(), SEEK(), WRITE(), WRITELINE()
Bob (who added the line of ^'s for emphasis)
--
Bob Stockler - bob at trebor.iglou.com
Author: MENU EDIT II - The BEST Creator/Editor/Manager for filePro User Menus.
Fully functional (time-limited) demos available by email request (specify OS).
More information about the Filepro-list
mailing list