Hello!
I'm processing a text file. I already formatted things so it contains everything necessary. The new line strings are in the text too, so I have text like this: some text here \n other text here, and so on \n some more text So I simply read in the text, give it to a string, and pass the string to an attribute. However the new lines are not created this way. If I simply add the attribute the new line string "\n ", it works, but by reading in a text file, it doesn't. Anybody has any idea why this may happen? Thank you in advance! Best regards, Peter HPM2BP - Wed Jul 26 05:20:32 EDT 2017 |
Re: Reading \n from file doesn't result new line If you really have the to characters "\n" inside your text file (and you are not only writing it this way to highlight the newlines), then it does not work this way. Inside a file only a newline is a newline, so unless your file looks like this: some text here other text here, and so on some more text You will not read any newlines. When you write the following DXL code: string s = "some text here \n other text here" print s Then the DXL parser will replace the "\n" inside the string literal by a newline character before executing the DXL. This obviously does not happen when reading a text file. maybe this helps, Regards, Mathias |
Re: Reading \n from file doesn't result new line I see, you are right. I forgot that when I'm reading a backslash from a text file, in the string it'll be equal with the "\\", not a single backslash. I'll try to make a workaround, thank you.
Best regards, Peter |