Hello, 

I have a question about the file reading in REBOL. Does Rebol has sth like EOF
(end of file) function? 

I wrote a script which read through a directory and does sth on each file.
I use a while loop to do this:

files: read %.
foreach file files [
    if find file ".dat
    [
        blk: read/lines file
        print join "processing on " file
        ;some code

        while [not empty? blk] ;maybe I should use sth else to test the end of
blk???
        [
            ; some code
            blk: next blk
        ]
    ]
]

when I run it. sometimes it gave me the error msg: 
processing on text1.dat
processing on text2.dat
processing on text3.dat
** Script Error: Out of range or past end.
** Where: d2: second (to-block first blk) 

Without changing anything I ran the same script again, the error msg is:
processing on text1.dat
processing on text2.dat
processing on text3.dat
processing on text4.dat
** Script Error: Out of range or past end.
** Where: d2: second (to-block first blk) 

It looks like text3.dat is ok for the second time.
When I change the .dat file (clear out the tail empty spaces manually), it
worked. but obviously I can't do that every time for each .dat file

This is so weird. Is this because of my files? or I use the wrong function to
test the end of the file?

Your help will be highly appreciated.

Tiana

Reply via email to