1. LineFeed and Textarea

Just a little question:

I have a text inside an EditText area. Every time the program executes the
following lines:
ft = open( filename, "w")
puts( ft, getText( fTextArea)) 
close( ft)
each text line is "enriched" by one more Line Feed, that is | 0D 0A |
characters.
After four such save operations (and reload), every line results spaced four
times (in a normal editor),
while it shows in the EU TextArea 4 unreadable symbols.

The whole file was read with the simple:

data = gets( fh)

I tried then the more laborious formula:

 while 1 do
     line = gets(fh)
     if atom(line) then
         exit  
     end if
     data &= line[1..length( line)-1]
 end while

and that problem does not repeat, but the text lines are no more spaced as due
by the Line Feed. All the text flows like a single line.

I think this question be welll known yet, but I don't know how to disentangle it
:(

Thanks to everybody.

Antonio

new topic     » topic index » view message » categorize

2. Re: LineFeed and Textarea

unknown wrote:
> Just a little question:
> 
> I have a text inside an EditText area. Every time the program executes the
> following
> lines:
> ft = open( filename, "w")
> puts( ft, getText( fTextArea)) 
> close( ft)
> each text line is "enriched" by one more Line Feed, that is | 0D 0A |
> characters.
> After four such save operations (and reload), every line results spaced four
> times
> (in a normal editor), 
> while it shows in the EU TextArea 4 unreadable symbols.
> 
> The whole file was read with the simple:
> 
> data = gets( fh)
> 
> I tried then the more laborious formula:
> 
>  while 1 do
>      line = gets(fh)
>      if atom(line) then
>          exit  
>      end if
>      data &= line[1..length( line)-1]
>  end while
> 
> and that problem does not repeat, but the text lines are no more spaced as due
> by
> the Line Feed. All the text flows like a single line.

I think the EditText expects {0D, 0A} or {0A, 0D} at the end of each line. So
after removing the last character of each line, try appending "\n\r" or "\r\n". I
think one of those should do it.

<code>
end_of_line = "\n\r" -- or "\r\n"
while 1 do
    line = gets(fh)
    if atom(line) then
        exit  
    end if
    data &= line[1..length( line)-1] & end_of_line
end while
</code>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu