Rebol FAQ and Rebol Seek
[1/3] from: rotenca::telvia::it at: 15-Sep-2002 16:15
Hi,
this code:
write %myfile.txt "abc"
file: open/binary/direct %myfile.txt
skip file 1
data: copy/part file 80
does not work under View 1.2.1.3.1 1.2.5.3.1 1.2.8.3.1. It freezes the Rebol
shell.
Am i doing something wrong?
It comes from REBOL FAQ:
005 How do I SEEK on a file so I don't have to read the entire file?
1-Jan-2000
Open the file with OPEN/BINARY/DIRECT and use SKIP to go to the selected
offset:
file: open/binary/direct %myfile.txt
skip file 2000
data: copy/part file 80
The above skips the first 2000 bytes of the file and then copies 80 bytes
starting from that location into DATA.
---
Ciao
Romano
[2/3] from: gscottjones:mchsi at: 15-Sep-2002 9:57
From: "Romano Paolo Tenca"
> this code:
>
> write %myfile.txt "abc"
> file: open/binary/direct %myfile.txt
> skip file 1
> data: copy/part file 80
>
> does not work under View 1.2.1.3.1 1.2.5.3.1 1.2.8.3.1. It freezes the
Rebol
> shell.
> Am i doing something wrong?
<<quoted lines omitted: 8>>
> The above skips the first 2000 bytes of the file and then copies 80 bytes
> starting from that location into DATA."
Hi, Romano,
This seems to be an error that has been mentioned frequently, and just as
often mentioned that it is curious that it hasn't yet been fixed. It is the
binary
refinement that causes the error. One can easily achieve the same
goal by doing a throw away copy/part, like:
write %myfile.txt "abc"
file: open/binary/direct %myfile.txt
;skip file 1
copy/part file 1
data: copy/part file 80
But this work-around misses the point that skip should be fixed for binary
files. Maybe the error/bug should be resubmitted to feedback.
Hope this helps clarify the mystery.
--Scott Jones
[3/3] from: rotenca:telvia:it at: 15-Sep-2002 18:31
Hi Scott,
> This seems to be an error that has been mentioned frequently, and just as
> often mentioned that it is curious that it hasn't yet been fixed. It is the
> "binary" refinement that causes the error.
...
> But this work-around misses the point that skip should be fixed for binary
> files. Maybe the error/bug should be resubmitted to feedback.
> Hope this helps clarify the mystery.
Thanks, it is strange that also in the new betas 1.2.5 and 1.2.8 the bug is
the same.
About Copy/part, it does not work when you want to write to the file (the
work-around is read-io, see
http://www.escribe.com/internet/rebol/m25388.html).
Now i realize that also the only /direct refinement creates problems to the
writing offset:
write f: %myfile.txt "abc"
file: open/direct f 1
skip file 1
insert file "k"
close file
read f ;== "abck"
---
Ciao
Romano
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted