1. Re: LineFeed on Textarea

Previous Message All Messages     
 
Re: LineFeed and Textarea    gue- at rapideuphoria.com  
  Apr 18, 2004 07:12 PDT   



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 = get_bytes( fh, dirinfo[1][D_SIZE])

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> 
	
If I cut the end_of_line (0D 0A) and then I add the same, the problem remains
unchanged.
I think that the real problem begins when I save the text,
not when I load it; cutting the last byte was just an attempt...

Who adds the CR or LF to the original text?	

Thanks again.

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu