- NSIS Discussion
- Howto change un-normal ini entries?
Archive: Howto change un-normal ini entries?
dbach
28th February 2008 10:39 UTC
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?
Red Wine
28th February 2008 10:44 UTC
I doubt if this is a proper INI when all entries have the same name.
dbach
28th February 2008 10:48 UTC
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. :|
Red Wine
28th February 2008 10:54 UTC
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
dbach
28th February 2008 11:18 UTC
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.dllOn 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.
Red Wine
28th February 2008 11:30 UTC
Then remove the old INI (no matter if the entry is written or not) and install a new one which includes myadded.dll.
dbach
28th February 2008 11:34 UTC
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). :-|
Red Wine
28th February 2008 11:43 UTC
Hmm! The INI has only one section, or several?
dbach
28th February 2008 12:01 UTC
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. :(
Red Wine
28th February 2008 12:40 UTC
What about this?
Afrow UK
28th February 2008 13:52 UTC
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
dbach
28th February 2008 13:55 UTC
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!
Red Wine
28th February 2008 14:11 UTC
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,