- NSIS Discussion
- .ini
Archive: .ini
Yathosho
4th March 2002 03:00 UTC
.ini
the software my installer is for saves the settings in a .ini file that looks like this:
[service 1]
setting_1=blabla
setting_2=blabla
[service 2]
setting_1=blabla
setting_2=blabla
is there a possibility to query for the highest number of the service ([service x])? the problem is, that the software does not except numbers that dont follow each other. service 1, service 2, service 999 - the last one would be ignored. if possible the installer checks the highest number and adds one using the value+1.
Smile2Me
4th March 2002 07:34 UTC
Killahbite,
I would suggest that you write a small Dll, because here you will need to compare successive numbers (<, > or =) and the first two are not possible using NSIS (I think). So just write a dll that takes to values (in the stack or in user variables) and returns the highest one.
Good luck,
greetz, Hendri.
Yathosho
6th March 2002 08:07 UTC
i wish i could do that
Smile2Me
6th March 2002 08:25 UTC
What is the problem?
-Hn3.
Smile2Me
6th March 2002 08:32 UTC
In NSIS, just try to create a loop that reads all sections:
"service $0"
During this loop, read the ini for this section and if the resulting string is nonempty, the section apparently exists, so set $R9 to this section number and continue in the loop.
In the end $R9 will contain the highest number of sections used.
But this could be slow, you could try...
Good luck, greetz,
Hendri.
Smile2Me
7th March 2002 08:45 UTC
Compare integers
Hi killahbite,
here's a dll to compare integers. Now it should be possible to write a script that finds the maximum. Just read every new section and if the number is larger than what you already have (using the dll) update the maximum. BTW, you will have to use FileRead instead of ReadIniStr because than you can just check the available sections and nothing more (more efficient!). Example script included.
Good luck, greetz,
Hendri.
Smile2Me
7th March 2002 09:11 UTC
The script to check an ini for highest numbered section
Hi killahbite,
as a special treat: here's the script to do the job. Please let me know if it's working like you would like to.
Greetz,
-Hn3.
eccles
7th March 2002 20:56 UTC
Hi Hendri,
Um, can't you just use IntCmp to compare two integers?
Sorry to be the bearer of bad news, after all that hard work... :)
--
Dave
Smile2Me
8th March 2002 07:11 UTC
Eccles, indeed, you could use IntCmp, :(
but I never used it before and I use all the other commands almost every day, so I forgot about this command...
Indeed, hard work for nothing...
Killahbite, implement IntCmp in the checkini script. Much more efficient :(
Good luck, greetz,
Hendri.
Yathosho
9th March 2002 00:34 UTC
ah cool, will check it tomorrow! thank you!
Smile2Me
9th March 2002 12:04 UTC
Hi killahbite,
a modified source, now using IntCmp...
Good luck with it, have fun, greetz,
-Hendri.
Smile2Me
25th March 2002 07:22 UTC
Jan,
here's the requested modification of checkini -> checkini1.zip
Good luck, greetz,
Hendri.
Smile2Me
26th March 2002 09:05 UTC
Someone might be interested in this:
a function that searches an ini for the number of keys starting with a numeric value (0,1,2,3,4,5,6,7,8 or 9) within a section you can choose yourself.
Have fun,
greetz, Hendri.
Yathosho
26th March 2002 12:54 UTC
thank you very much hendri, you rock :D
Smile2Me
26th March 2002 12:57 UTC
Killahbite,
thx for the appreciation, it's nice to do something for people who appreciate it :).
Greetz, Hendri.