PDA

View Full Version : adding to existing files and not replacing


Cyong
18th July 2006, 05:53
ok i got an interesting problem, i have a game that is customizable so that people can put in their own charecters.

The file listing the directory of each charecter is pretty straight forward

<Name>x2</name>
<Name>x3</name>
<Name>x4</name>
<Name>x5</name>
<Name>x6</name>

now people can add any charecter they want so the file can easily change and look like

<Name>x2</name>
<name>Custom</name>
<Name>x3</name>
<Name>x4</name>
<Name>x5</name>
<Name>x6</name>

in updates i want to be able to simply add the new lines of code to the file instead of just replacing it, that way my users wont have to re-edit the file after every update. any suggestions?

Afrow UK
18th July 2006, 10:16
Try this function:
http://nsis.sourceforge.net/Write_to_text_file_line_number

If you don't know what line to write to, you can use:
http://nsis.sourceforge.net/ReplaceBetween:_Replace_text_between_two_markers_in_a_file
And replace between </name> and <Name>.

These functions are old, so I also recommend using the TextReplace plugin (http://nsis.sourceforge.net/File:Textreplace.zip).

-Stu

Cyong
19th July 2006, 07:15
Originally posted by Afrow UK
Try this function:
http://nsis.sourceforge.net/Write_to_text_file_line_number

If you don't know what line to write to, you can use:
http://nsis.sourceforge.net/ReplaceBetween:_Replace_text_between_two_markers_in_a_file
And replace between </name> and <Name>.

These functions are old, so I also recommend using the TextReplace plugin (http://nsis.sourceforge.net/File:Textreplace.zip).

-Stu

hmm thanks, might have to change a few things (add a line at the bottom of the code to spcify what can be replaced) but it should do the trick. Thanks