Archive: Howto change un-normal ini entries?


Howto change un-normal ini entries?
Hi together.

I have a problem with an .ini file. It looks like this:
[section]
entry = whatever.dll
entry = another.dll
entry = andsoon.dll

When I say "writeinistr" it replaces the first 'entry' with the new value. :|

How can I arrange this?


I doubt if this is a proper INI when all entries have the same name.


Originally posted by Red Wine
I doubt if this is a proper INI when all entries have the same name.
Thanks for your reply.
My problem is that the main product is already released and my installation is an addon for this product which requires to add this setting.
Any ideas?

Edit: I talked to one of the devs. He told me that they just read the "entry"'s in a array and uses them. Of course, the .ini isnt nicely designed but I still need to fix this problem. :|

You may use word functions header to find/replace the required value, however, I guess you understand that the INI is useless whatsoever.

http://nsis.sourceforge.net/Docs/AppendixE.html#E.3


Originally posted by Red Wine
You may use word functions header to find/replace the required value, however, I guess you understand that the INI is useless whatsoever.

http://nsis.sourceforge.net/Docs/AppendixE.html#E.3
Well my problem is that I don't know what to find bcs the value doesn't exists yet and has to been included to the section so that it looks something like this:

[section]
entry = whatever.dll
entry = another.dll
entry = andsoon.dll
entry = myadded.dll

On unInstall I could use a WordReplace function but I have currently no idea how to
.) check if this entry was already written to the ini
.) add the entry without destroying another value

Thank you very much for your help so far, Red Wine!

Edit: The programm itself (for which the INI settings for) has no problems parsing the INI file and using the values. The only problem is myself adding more ununique values.

Then remove the old INI (no matter if the entry is written or not) and install a new one which includes myadded.dll.


Originally posted by Red Wine
Then remove the old INI (no matter if the entry is written or not) and install a new one which includes myadded.dll.
Also not possible bcs values could have been changed in this ini as well (its one big .ini file with settings for nearly all settings). :-|

Hmm! The INI has only one section, or several?


Originally posted by Red Wine
Hmm! The INI has only one section, or several?
The Ini has serveral sections with unique names, but in the sections the names are not longer unique. :(

What about this?


Easiest solution is to loop through the existing file and compare each line with entry = myadded.dll$\r$\n. If that line isn't found, seek to the end then write the new line.

Stu


Thanks for you replies. I will test the init.zip today (very special thanks!!) and report if its working for me. A dev told me that if he has to much time he will write a command-line util for me that handles this behaviour.

Thanks all!


The example above works fine if the entry doesn't exist, though, it fails when the entry already exists.

The following example should work in every case,