Archive: ReWriting INI files (the hard way?) :-(


ReWriting INI files (the hard way?) :-(
  Hi together.

I am currently writing an upgrade installation for one of our products.
In the old ini file I have some sectionnames that have to move to a new ini file - but as values!

Example:

; Old.ini

>***91;AETITLE:MachineName***93;
>a=b
x=y

>***91;AETITLE:AnotherMachineName***93;
>l=m
n=o
>
I need the Name of the Section without AETITLE. The result should look like this:


ini

>***91;network***93;
>MachineName=one-setting,more-settings,yadada
AnotherMachineName
=one-setting,more-settings,yadada
>
I do not need the values/keys from the old.ini sections but part of the sectionname as value for the new.ini.

Any ideas how to handle this? :|

Thank you very much.

ConfigRead should be of help


thanks for your reply.

my problem is that i don't know the section names yet. they all start with [AETITLE:something], so I will need a loop. but I didn't program a loop so far. Any hints about looping trough my problem? or can anyone point me to a good example with loops which also I can unterstand? ;)

thnx


try this


 ClearErrors


Loop:
${
ConfigRead} "old.ini" "***91;AETITLE" $var ; sets errorflag if not found
IfErrors EndLoop
StrCpy $var $var-1 ; deletes the "***93;"
>WriteIniStr "new.ini" "network" $var "what you want to add"
>DeleteINISec "old.ini" "***91;AETITLE$var***93;"
Goto Loop
EndLoop:
the DeleteIniSec part is probably undesired and clumsy, but you get the idea with the loop

Originally posted by Yathosho
try this

 ClearErrors


Loop:
${
ConfigRead} "old.ini" "***91;AETITLE" $var ; sets errorflag if not found
IfErrors EndLoop
StrCpy $var $var-1 ; deletes the "***93;"
>WriteIniStr "new.ini" "network" $var "what you want to add"
>DeleteINISec "old.ini" "***91;AETITLE$var***93;"
Goto Loop
EndLoop:
the DeleteIniSec part is probably undesired and clumsy, but you get the idea with the loop
thank you very very much! thats exactly what I need.