Dialog new line problem
#1

I would like to know, if it's possible to store text from a file (for example "1st line\n2nd line\n3rd line") to a variable and then put it in a dialog so it would look like this:

Код:
1st line
2nd line
3rd line
I'm asking because I need it for a script which I'm doing and it doesn't work... If I would use this example it would look like this:

Код:
1st line\n2nd line\n3rd line
So am I doing it wrong and if I am, how to script it so it will work?

Thank you for your help and sorry if you didn't understand me properly, I wasn't born in English speaking country.
Reply
#2

The problem most likely is that you are reading \n from the file and inserting it directly into the string. The important thing to remember is that \n by itself is not a new line, the compiler is what makes that a new line. Since your reading the data from a file, it's not going through the compiler, and not creating the new line. You will need to go through the string, after inserting it into an array from the file, and replacing all appearances of \n with \\n.

Credits to ****** in another thread for pointing this out (I just can't seem to find it at the moment).
Reply
#3

So I tried to script the replacement of \n with \\n and I'm probably doing it wrong, because it shows "1st line\nn2nd line\nn3rd line" and not the "1st line\\n2nd line\\n3rd line" which would divide the text into the lines as you said.


Here's the code:

Код:
for (new a = 0; Obsah[a] != '\0'; a ++)
{
     if (Obsah[a] == 92 && Obsah[a+1] == 110)
     {
          strdel(Obsah, a, a+1);
          strins(Obsah, "\\n", a, sizeof(Obsah));
								
	  a = a + 2;
     }
}
Edit: I've fix it and it works. Thanks for the help Bakr.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)