Save text from a Textarea line-by-line?!
BlitzMax Forums/MaxGUI Module/Save text from a Textarea line-by-line?!
| ||
Hi guys! In my textarea I have different strings displayed with a chr(13) linestop like: Line1 Line2 Line3 I save the complete contents of the textareafield into a file via: SaveText (TextAreaText(mytextarea),"my.txt") The resulting file looks like: Line1Line2Line3 Is this a bug? - Any simple workarounds present? Thanks Grisu |
| ||
Try using "~n" Chr(10) instead of "~r" Chr(13) to end your lines. Also, this can happen when text files are open in Notepad as Notepad only understands Windows convention (CR+LF, i.e. "~r~n") - try opening the file in WordPad instead and it may appear OK. |
| ||
To clarify my issue: 1. I create a text file with "writeline" 2. Then I load the text file via "loadtext" into a textarea 3. At the end I save the textarea via "savetext" The resulting file is different from the original one created via "writeline". Seems like the chr(13) linebreaks got deleted on the way. Though they look fine inside the textarea. |
| ||
So WriteLine and LoadText use different end-of-line conventions? What is the best cross-platform solution? I think the three common versions are: Chr(10) for Unix/Linux Char(13) for Mac Char(13)+Chr(10) for Windows, and DOS if anybody cares. |
| ||
Thanks for the help, you got me on the right track there. When a text is loaded into a textarea chr(13) chars are transformed into chr(10) ones. Don't ask me why. As workaround I search every line of the textarea by chr(10) and save this single line to my textfile. Rather slow but works great. :o) |