SaveText TextAreaText screws-up text file

BlitzMax Forums/BlitzMax Programming/SaveText TextAreaText screws-up text file

Steve Elliott(Posted 2010) [#1]
Using...

 SaveText TextAreaText(IDEText), ProgName


Screws up the formatting of a text file created in Notepad (puts everything on one line).

It's fine for reading back in BlitzMax or Wordpad, so you could call it a feature. ;-) But it's causing my C++ program that reads the file problems.


skidracer(Posted 2010) [#2]
This is a Windows issue as Notepad .txt features non industry standard line endings (similar to your C++). Try the following if you are Windows only, otherwise maybe you could fix your C++?

			Local mstext$=TextAreaText(textarea).Replace("~n","~r~n")
			SaveText mstext,"c:\test.txt"



xlsior(Posted 2010) [#3]
some slightly more clarification: Under Linux/Unix/mac/etc. the standard end of a line in text files is just a Newline (chr$(10)) while under DOS/windows you'll need a carriage return AND a newline.

You can also see that difference in behaviour in most FTP programs: those will detect hostype, and typically automatically replace the end-of-line characters for downloaded files depending on the platform that you are on if you transfer the files in ASCII mode.

Note that if you open the file in write / wordpad instead of notepad it does parse it out correctly. For occasional issues you can open in wordpad and save as .txt, this will use the default windows line-ends, after which you can open it without weirdness in notepad again as well.


TaskMaster(Posted 2010) [#4]
Not sure I would call this non-industry standard.

It all goes back to the old teletype days.

A newline causes the cursor to go down one line, a carriage return causes the cursor to move to the beginning of the line.


Steve Elliott(Posted 2010) [#5]

This is a Windows issue as Notepad .txt features non industry standard line endings (similar to your C++). Try the following if you are Windows only, otherwise maybe you could fix your C++?



Thanks for the info and code skidracer. I did manage to fix my C++ code though.