I am using a TextField in my program to enter text. I am then outputting the text in this TextField to a text file. This will then be read into a different program to be displayed.
The problem I’m running into is that, when I write the text to the text file, its not preserving line breaks. This, of course, means that when I read it into the second program, it will come in as one long string.
Is there some way to get the line breaks in the text field to output to the text file (such as “/n”)?
Another possibility; is there some way I can just generate a “/n” when the user presses the Return key while the text field is selected?
I’m not concerned about what it looks like while entering or outputting the text. My only concern is what it looks like once it’s read into and displayed in the final program.
I can create (if I need to) a function to change /n into a new line in the final program. I just need some method for creating the /n when creating the text file.
There aren’t any line breaks in the text for a TextField; it’s one line of text, word-wrapped as necessary. So you’d have to do the word-wrapping yourself somehow in order to know where the “line breaks” would be for a given TextField.
In that case, a TextArea does include the line breaks in the string. If you’re using Windows and looking at the output in a text editor or something, it may not recognize the “\n” character as a line break (it might need “\r\n”).
Yes, the linebreak does show up in the original program, but when writing that out to a text file, I get this:
…err… wait…
k, I just pasted this from the text file and the linebreaks are apparently there. Will this just read into the program correctly then? Its just “Notepad” that isn’t displaying the linebreaks?