Hi Tim,
1. Your code causes an error, before it completes executing:
>> fp: open/lines/write %test.txt
>> forall fp
** Script Error: forall expected body argument of type: block.
** Where: forall fp
2. help open states that:
>> help open
Opens a new port connection.
Arguments:
spec -- (file url port object block)
Refinements:
/write -- Write only. Disables read operations.
The /write refinement disables read operations!
Solution:
Use the /mode refinement with a block [lines read write] like this:
>> print read %test.txt
line one
line two
line three
line five
>> fp: open/mode %test.txt [lines read write]
forall fp [
if found? find first fp "three" [
insert next fp "line four"
]
]
== false
>> update fp
>> close fp
>> print read %test.txt
line one
line two
line three
line four
line five
;- Elan >> [: - )]
- [REBOL] Rebol Web Server woodward
- [REBOL] Rebol Web Server Re: Al . Bri
- [REBOL] Does REBOL support multiple instances of... steveb
- [REBOL] [REBOL] Reading text a line at a time tjohnson
- [REBOL] [REBOL] Reading text a line at a tim... allenk
- [REBOL] [REBOL] Reading text a line at a tim... Al . Bri
- [REBOL] [REBOL] Reading text a line at a tim... icimjs
- [REBOL] [REBOL] Updating a file as a por... tjohnson
- [REBOL] [REBOL] Updating a file as ... icimjs
- [REBOL] [REBOL] Updating a file... jimg
- [REBOL] [REBOL] Updating a ... icimjs
- [REBOL] [REBOL] Updating a ... icimjs
- [REBOL] [REBOL]Update file as p... tjohnson
- [REBOL] [REBOL]Update file ... icimjs
- [REBOL] [REBOL]Update file ... tjohnson
- [REBOL] Update file as port... icimjs
- [REBOL] Update file as port... jimg
- [REBOL] Update file as port... Petr . Krenzelok
- [REBOL] Update file as port... icimjs
