That looks OK.
Perhaps there's a problem with the code in the 'while.

Andrew Martin
Sleepy REBOL...
ICQ: 26227169
http://members.xoom.com/AndrewMartin/
-><-



----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, 16 February 2000 4:09 AM
Subject: [REBOL] EOF? Help please


> 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