Removing entry (fwrite) - 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: Removing entry (fwrite) (
/showthread.php?tid=483269)
Removing entry (fwrite) -
erminpr0 - 24.12.2013
How to remove entry in fwrite, like with INI - INI_RemoveEntry.
I am using INI because I'm beginner, but wanna try to understand fwrite as more as I can, for other things, not SA:MP.
E.g.
new File:file = fopen("somefile.txt", io_read);
fremoveentry(file, "Test2");
fclose(file);
Would be:
Thanks anyway!
Re: Removing entry (fwrite) -
Basssiiie - 25.12.2013
There's no easy way to do something like that. Pawn's default file functions can't "insert" or "remove" characters in between. By default each character in the text file is fixed to its position in the file. For example if the T of "Test3" is the 15th character in the file, you can only move it to the 8th place by rewriting the whole file from the 7th place until the end of the file. Otherwise you would keep the gap of 7 other characters in between, because you removed the info there while the next line is still positioned at the 15th spot. Furthermore, if you want to write 10 characters in that gap, it would overwrite some characters of the next line.
I hope it's a clear answer, I don't really know how to describe it otherwise.
Re: Removing entry (fwrite) -
leonardo1434 - 25.12.2013
The easiest way is to store every line of your file into buffer, find the line, remove it from buffer, and then skip it while re-writing the file.
Re: Removing entry (fwrite) -
erminpr0 - 25.12.2013
A'ight guys, thank you.