Jump to content

ini Section Deletion


Recommended Posts

Hello, This has been a major problem for quite some time now, and i have been determined to figure it out on my own (to improve my logic and programming skills) but its become a little to complicated and i would really appreciate some help...

I have a GUI, with a ListView, the ListViewItems are read into it by a loop that reads section headings from an ini file... i have a delete button that deletes the selected item in a ListView, i need to know how to read the first column of each item into an array, compare the section headers to the array elements, and if a section header has no match, i need to delete that section in the ini.

so far this is what i have come up with:

Func FileSave()
    $Section = IniReadSectionNames("Diablo II Bot.ini")
    If @error Then 
        MsgBox(4096, "Error:", "No '.ini' File Found.")
    Else
        $Count = _GUICtrlListViewGetItemCount($ListView1)
        Local $Temp[$Count]
        For $h = 0 To $Count - 1
            $Item = _GUICtrlListViewGetItemTextArray($ListView1,$h)
            For $i = 1 To $Count + 1
                If $Section[$i] = "Global Information" Then
                Else
                _ArrayAdd($Temp, StringInStr($Section[$i], $Item[1]))
                EndIf
            Next
            If _ArrayMin($Temp, 1) = _ArrayMax($Temp, 1) Then
                IniDelete("Diablo II Bot.ini", $Item[1])
            EndIf
        Next            
    EndIf
EndFunc

i read the section names, check for an error, count the ListViewItems, Create a local Array, Loop to find the ListViewItem Text, Loop to fill the array with the value returned by StringInStr(), check if the max and min values of the array are equal, and if so, delete the section, if not, loop to find and compare next ListViewItem...It was the only way i could think of doing it at the time, but it doesnt seem to work, i hope someone can help me with this...

This may be a little confusing...ill post this, and try to think of a way to reword what im asking for... then ill edit it later.

Thank You.

Edited by Naufuge
Link to comment
Share on other sites

  • Moderators

If I'm understanding correctly what your needing, I helped th.meger with something similar here:

http://www.autoitscript.com/forum/index.ph...ndpost&p=167638

Maybe you can get an idea off that.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

ok i did read through some of that, but i was busy and had to leave soon afterwards... ill look at it a gain later, i managed to get ot so when i select one and press delete, it removes it from the list, then when i press save, it deletes everyother one except the one i selected...its kinda weird... but with a little tweeking im sure i can get it...

Thanks

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...