Jump to content

Recommended Posts

Posted

I have a list of keys and wish to save it to an ini section overwriting the entire section. So I came up with this code that needs some fine tuning I believe. The number of keys may vary from time to time so the the entire section needs to be cleared more or less but keeping the rest of the sections as is. I did have the IniWriteSection portion of my code working somewhat with out the "key"&$J&"="& but I need it in there somehow. I hope you pros can help me out a little.\

Thanks.

Func savelist()
For $i = 1 To $inisize -11                             ;Delete all existing keys in ini file section
    IniDelete("My.ini", "Section2", "key"&$i)
Next

 $Count = _GUICtrlListBox_GetCount ( $mylist )                 ;Save all of list to ini file WITH "key="
   For $J = 0 To $Count -1
     IniWriteSection("My.Ini", "Section2", "key"&$J&"="&_GUICtrlListBox_GetText ($mylist,$J))
   Next
EndFunc
AutoViewer first public AutoIt script
Posted

You don't need to use IniWriteSection unless you have an array of data to be written into.

Func savelist()
For $i = 1 To $inisize -11                            ;Delete all existing keys in ini file section
    IniDelete("My.ini", "Section2", "key"&$i)
Next

$Count = _GUICtrlListBox_GetCount ( $mylist )                 ;Save all of list to ini file WITH "key="
   For $J = 0 To $Count -1
     IniWrite("My.Ini", "Section2", "key"&$J,_GUICtrlListBox_GetText ($mylist,$J))
   Next
EndFunc

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Posted (edited)

Nevermind I figured it out, just had to take a break and have beer. For those that stumble across this in the future here is my solution. I hope it helps some people.

Instead of getting "key1=value, key2=value" you get "1=value, 2=value" which works just the same.

Func savelist()
For $i = 1 To $inisize -11                           ;Delete all existing keys in ini file section
    IniDelete("My.ini", "Section2", $i)
Next

 $Count = _GUICtrlListBox_GetCount ( $mylist )               ;Save all of list to ini file WITH "key="
   For $J = 0 To $Count -1
     IniWrite("My.Ini", "Section2", $J+1, _GUICtrlListBox_GetText ($mylist,$J))
   Next
EndFunc

Posted at the same time, thanks for your solution enaiman anyways.

Edited by DVHRLD
AutoViewer first public AutoIt script

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...