[REBOL] Re: areas, text, and read/binary
From: reboler:programmer at: 12-Feb-2002 12:39
Thanks, Brett and Joel, for your responses.
Here is a script to play around with so you can see what I mean.
You may need to look at this with a text viewer (such as NotePad) to see the changes.
Watch the file size change as you read/write.
;***** cut and paste the following into the console
write %test.txt {
test text
line 2,
line 3
line 4
write and read this file several times
while adding some text to the middle and end of lines
and then open in a text editor like NotePad
line 8
.
line 10
}
rebol []
file: %test.txt
main: layout [
across
my-area: area
return
text "Change what the Read button does, here"
return
read-field: field 400 "append clear my-area/text to-string contents: read/binary file"
button "Read File" [
do read-field/text
show my-area
]
return
text "Change what the Write button does, here"
return
write-field: field 400 "write/string file my-area/text" ;*****
button "Write File" [
do write-field/text
clear my-area/text
show my-area
sz: length? read file
append clear st/text rejoin ["size of file " length? read file]
show st
]
return
st: text rejoin ["size of file " length? read file]
return
button "Convert Lines" [write file read file]
text {This button does "write file read file"}
]
view main