Archive: WriteINIStr feature


WriteINIStr feature
In this thread: http://forums.winamp.com/showthread....ht=writeinistr
Kichik says

You can't assign more than one value to a certain entry in an INI section. If that was possible you couldn't have changed entries.

Use Delete /REBOOTOK.
The Unreal engines (UT, UT2, and expectedly UT3) use .ini files to pass package information to the engine, and can be stacked. Here are two sections from one of the .ini files:


[Core.System]
PurgeCacheDays=0
SavePath=..\Save
CachePath=..\Cache
CacheExt=.uxx
Suppress=DevLoad
Suppress=DevSave
Suppress=DevNetTraffic
Suppress=DevGarbage
Suppress=DevKill
Suppress=DevReplace
Suppress=DevSound
Suppress=DevCompile
Suppress=DevBind
Suppress=DevBsp
Paths=..\System\*.u
Paths=..\Maps\*.dx
Paths=..\Textures\*.utx
Paths=..\Sounds\*.uax
Paths=..\Music\*.umx
Paths=..\System\Demos\*.dem

[DeusEx.DeusExGameEngine]
CacheSizeMegs=16
UseSound=True
ServerActors=IpDrv.UdpBeacon
ServerActors=IpServer.UdpServerQuery
ServerActors=IpServer.UdpServerUplink MasterServerAddress=master0.gamespy.com MasterServerPort=27900
ServerPackages=DXMTL152b1
ServerPackages=DXIpServer.u
ServerPackages=DXMapVote100
ServerPackages=smg_mod
ServerActors=MiniMTL13.MiniMTL
ServerPackages=MiniMTL13
ServerActors=MMSkinsV01.SkinsMutator
ServerPackages=MMSkinsV01


With my installer, I would like to offer the user the ability to add various ServerPackages= lines, yet WriteINIStr would of course overwrite redunant occurances. Right now, in my installer's current form, I read lines from a text-file and re-write the .ini using FileWrite insertions . I don't see a "clean" way to insert and remove ServerPackages= lines except by the sloppy process or writing a text file and inserting new packages one-by-one, which seems cumbersome and sloppy.

So...

Is there a way, or a plan, to have WriteINIStr allow repeat entries?
...A simple flag like /a for "/append" similar entry_name parameters.

WriteINIStr ini_filename section_name entry_name value

...I'm not much of a programmer, so using Perl or Python isn't really an option for me, especially since the WriteINIStr function in NSIS seems so close to being capable of what I need without tons of extra work for any future changes, so I'm open to suggestions.

I'd recommend it as a feature to implement in the next build since a few other posts on this forum have referenced the .ini files of various UT-engine games.

WriteINIStr uses the windows API to write to the file and this api only supprots a single item per entry.

not sure if this ugly hack works but u could give it a try:
WriteINIStr "somefile.ini" "sec" "a" "1$\r$\na=2"


That would work, yes, but I was hoping to make a series of self-installing add-ons which would append themselves to the existing .ini section. Looks like the long-route, I suppose.


you will have to do that with various string and file functions.
have a look at the stringfunc/wordfunc and filefunc header files. they contain some macros that may help you.