Added keys are not being written to my INI file in the same sequence as the program is executing .Set.
To see the symptoms, here is a dump of the Keys (created using .GetKeys()) just before doing the .Save. Note the location of "VPot14":
PluginType
NumVPots
VPot0
VPot1
VPot2
VPot3
VPot4
VPot5
VPot6
VPot7
VPot8
VPot9
VPot10
VPot11
VPot12
VPot13
VPot14
VPot15
M2VPot0
M2VPot1
M2VPot2
M2VPot3
M2VPot4
M2VPot5
M2VPot6
M2VPot7
M3VPot0
M3VPot1
M3VPot2
M3VPot3
M3VPot4
M3VPot5
M3VPot6
M3VPot7
M4VPot0
M4VPot1
M4VPot2
M4VPot3
M4VPot4
M4VPot5
M4VPot6
M4VPot7
After the .Save, the updated INI file shows "VPot14" at the end:
[FxEq]
PluginType=1
NumVPots=16
VPot0=1,freq ; Band 1 Freq
VPot1=2,freq ; Band 2 Freq
VPot2=3,freq ; Band 3 Freq
VPot3=4,freq ; Band 4 Freq
VPot4=5,freq ; Band 5 Freq
VPot5=6,freq ; Band 6 Freq
VPot6=7,freq ; Band 7 Freq
VPot7=8,freq ; Band 8 Freq
VPot8=0,boost/cut ; Boost Trim
VPot9=54,switch ; Shelf Enable
VPot10=9,freq ; Lo Shelf Freq
VPot11=43,level ; Lo Shelf Boost
VPot12=10,freq ; Hi Shelf Freq
VPot13=44,level ; Hi Shelf Boost
VPot15=45,switch ; Global Enable (Bypass)
M2VPot0 = 19,spread ; Band 1 Q
M2VPot1 = 20,spread ; Band 2 Q
M2VPot2 = 21,spread ; Band 3 Q
M2VPot3 = 22,spread ; Band 4 Q
M2VPot4 = 23,spread ; Band 5 Q
M2VPot5 = 24,spread ; Band 6 Q
M2VPot6 = 25,spread ; Band 7 Q
M2VPot7 = 26,spread ; Band 8 Q
M3VPot0 = 35,level ; Band 1 Boost
M3VPot1 = 36,level ; Band 2 Boost
M3VPot2 = 37,level ; Band 3 Boost
M3VPot3 = 38,level ; Band 4 Boost
M3VPot4 = 39,level ; Band 5 Boost
M3VPot5 = 40,level ; Band 6 Boost
M3VPot6 = 41,level ; Band 7 Boost
M3VPot7 = 42,level ; Band 8 Boost
M4VPot0 = 46,switch ; Band 1 Enable
M4VPot1 = 47,switch ; Band 2 Enable
M4VPot2 = 48,switch ; Band 3 Enable
M4VPot3 = 49,switch ; Band 4 Enable
M4VPot4 = 50,switch ; Band 5 Enable
M4VPot5 = 51,switch ; Band 6 Enable
M4VPot6 = 52,switch ; Band 7 Enable
M4VPot7 = 53,switch ; Band 8 Enable
VPot14= <<<<<<< out of sequence
If the next section is preceded by a blank line, then the added Keys will be added after the blank line -- despite the fact that ALL keys have been removed.
I've been unable to trace through the Nini code to the root of the problem.
One possibility is there is some form of memory because the INI file did not contain the "VPot14=" entry when the file is opened. However, my program deletes all of the Keys and then adds them back (.Set). I verified that the keys had been removed both by examining memory (configList.list) and by executing .GetKeys(). It's almost like Nini says it has removed the Keys, but secretly it remembers.
I've spent hours trying to understand Nini internals and experimenting with potential solutions in my code to no avail. (Various comment settings; GC.Collect(); timing delays, etc.) The internals of Nini are beyond my present skill level so I've avoided trying changes there. I'm using the original downloaded Nini NET 2.0 debug DLL in conjunction with VS2005.
I have no control over the syntax of this INI file, i.e., the program reading it is a commercial product and is very picky.
Thanks,
Ed
Logged In: YES
user_id=1670306
Originator: YES
I've created and uploaded a demonstration program that reproduces the key sequence problem. I was focused on the [Second section], but examination of the output ini file shows that the same issue occurred with the "0=" key in the [First section].
For my app, after spending over a day with Nini internals, I gave up and used StreamWriter to create my output file from scratch using Nini's data.
File Added: NiniKeySequence.zip
Repeatable recreation of key sequence problem
Logged In: YES
user_id=1670306
Originator: YES
I've created and uploaded a demonstration program that reproduces the key sequence problem. I was focused on the [Second section], but examination of the output ini file shows that the same issue occurred with the "0=" key in the [First section].
For my app, after spending over a day with Nini internals, I gave up and used StreamWriter to create my output file from scratch using Nini's data.
File Added: NiniKeySequence.zip
Repeatable recreation of key sequence problem
Logged In: YES
user_id=163900
Originator: NO
Off the top of my head I don't know what the problem is here. It might be an issue with the OrderedList class.