gokuta Posted May 4, 2014 Share Posted May 4, 2014 (edited) I need to add new line to a text file. File is opened as text file (not binary) because I need to put some symbols there too. What opcode (or several opcodes) should I use? Edited May 4, 2014 by gokuta Link to comment https://gtaforums.com/topic/706213-add-new-line-to-text-file/ Share on other sites More sharing options...
Ashwin.Star Posted May 5, 2014 Share Posted May 5, 2014 (edited) Write "0D 0A" these two bytes to the File,in order to start from a new Line, Edited May 5, 2014 by Ashwin the new boy Link to comment https://gtaforums.com/topic/706213-add-new-line-to-text-file/#findComment-1065319229 Share on other sites More sharing options...
Deji Posted May 5, 2014 Share Posted May 5, 2014 (edited) If you're doing this with CLEO 4, you can use a trick to get over the lack of escape sequences in SB: 0ACE: print_help_formatted "Line #1%cLine #2" 0xAThe %c specifier in format strings will read the value of any number and display it as the relevant ASCII character. 0xA is the '\n' newline character. This should print 2 lines of help text. Similarly, if you want to output a new line to a file: 0AD9: write_formatted_string_to_file 0@ format "My File...%c" 0xAHowever, this will only work if you've opened the file in text mode, as the 0xA will actually be translated to 0x0D0A, as that is the proper way to end lines in files on Windows. If you were to open it in plain binary mode, you'd have to write that yourself: 0AD9: write_formatted_string_to_file 0@ format "My File...%c" 0x0D0A EDIT: As all CLEO commands commonly just bridge functions from C libraries, here is the reference for fopen - with links to similar file IO functions you may find in CLEO (fread/fwrite/etc.): http://www.cplusplus.com/reference/cstdio/fopen/ Edited May 5, 2014 by Silent villana 1 Link to comment https://gtaforums.com/topic/706213-add-new-line-to-text-file/#findComment-1065321293 Share on other sites More sharing options...
gokuta Posted May 5, 2014 Author Share Posted May 5, 2014 Thanks, Deji (and Ashwin), that was helpful. Sorted! Link to comment https://gtaforums.com/topic/706213-add-new-line-to-text-file/#findComment-1065321985 Share on other sites More sharing options...
Recommended Posts