SA-MP Forums Archive
Little help with line break - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Little help with line break (/showthread.php?tid=286434)



Little help with line break - FireCat - 28.09.2011

Does anyone know why isn't this line breaking
Like instead of appearing, in my file, like this:
1,
2,
3,
It appears
1,2,3
Anyone know why?
pawn Код:
ew File:example = fopen("Admin/Logs/Labels.txt", io_append);
        format(string,sizeof(string),"%f,%f,%f,%s,%i,%i;\n",x,y,z,currenttext,color,currentistele);
        fwrite(example,string);
        fclose(example);



Re: Little help with line break - iggy1 - 28.09.2011

You only use one line break at the end. If you want all values on separate lines put a line break after each value. Unless i misunderstood you.


Re: Little help with line break - [L3th4l] - 28.09.2011

Change "\n" to "\r\n". Honestly, not sure if that's going to work ( I'm not sure what \r means, but that's how I have it, and that's how it works for me )


Re: Little help with line break - FireCat - 28.09.2011

Quote:
Originally Posted by [L3th4l]
Посмотреть сообщение
Change "\n" to "\r\n". Honestly, not sure if that's going to work ( I'm not sure what \r means, but that's how I have it, and that's how it works for me )
Lol xD Ok trying it now, I'll edit this post :b


Re: Little help with line break - iggy1 - 28.09.2011

Quote:
Originally Posted by [L3th4l]
Посмотреть сообщение
Change "\n" to "\r\n". Honestly, not sure if that's going to work ( I'm not sure what \r means, but that's how I have it, and that's how it works for me )
"\r" is carriage return, it will start the next line aligned to the left i believe, so text on a new line doesn't start in the middle.

EDIT: Just read up "\r". It moves the cursor to the beginning of the current line.


Re: Little help with line break - FireCat - 28.09.2011

Quote:
Originally Posted by iggy1
Посмотреть сообщение
You only use one line break at the end. If you want all values on separate lines put a line break after each value. Unless i misunderstood you.
It was an example I gave...


Re: Little help with line break - [L3th4l] - 28.09.2011

Quote:
Originally Posted by iggy1
Посмотреть сообщение
"\r" is carriage return, it will start the next line aligned to the left i believe, so text on a new line doesn't start in the middle.

EDIT: Just read up "\r". It moves the cursor to the beginning of the current line.
Thanks for this valuable info!


Re: Little help with line break - iggy1 - 28.09.2011

Quote:
Originally Posted by FireCat
Посмотреть сообщение
It was an example I gave...
Yeah i think i misunderstood you, i thought you wanted values on each line silly me.


Re: Little help with line break - FireCat - 28.09.2011

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Yeah i think i misunderstood you, i thought you wanted values on each line silly me.
No problem :b
Like in my code, it still loads it all correctly but it looks horribly coded in the file.
But it writes for example like this
1.2,3.4,5.9,Hello,4,1;3.7,4.8,3.1,Herro,5,2;
All in the same line, and I would like it to write like this:
1.2,3.4,5.9,Hello,4,1;
3.7,4.8,3.1,Herro,5,2;