Jump to content

Problem with INIReadSection and ListView


NELyon
 Share

Recommended Posts

Ok, I'm working on a phone book-phone manager for Adcalls that gives you access to your favorite numbers at your finguhtips.

I figured an INI would be the easiest way to manage this, so i took a look at INIReadSection. Of course, it's arrays so I'm already bound to have some problem with it :P

Heres my code so far.

#Include <GUIConstants.au3>
GLobal $ii
FileWrite(@ScriptDir &"\Phonebook.ini", "")
$GUI = GUICreate("BeUrSelf Phone Thing") ; Displays a GUI that is... some width and height i guess
$List = GUICtrlCreateList("", 5, 5, 280, 300)
$Menu1 = GUICtrlCreateMenu("&Help")
$MPhoneBook = GUICtrlCreateMenuitem("How to use Phonebook", $Menu1)
$ButtonUpdate = GUICtrlCreateButton("Update Phone Book", 290, 10)
GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            Exit
        Case $MPhoneBook
            MsgBox(0, "How to use Phonebook", "Ok, there is a file called Phonebook.ini in your script directory"&@CR&"Take this file and fill out the phone book like this:"&@cr&"[phonebook]"&@cr&"1=Number"&@cr&"2=number"&@cr&" and so on. Then click the Update button. The phonebook shoud load")
        Case $ButtonUpdate
            $ii = IniReadSection(@ScriptDir &"\Phonebook.ini", "phonebook")
            For $i = 1 to $ii[0][0]
                GUICtrlSetData($List, $ii[0][$i])
                If @Error Then MsgBox(0, "", "You haven't set up a Phonebook yet!")
            Next
            
    EndSwitch
WEnd

The strange thing is, if i take the INI and give it one value, it silently errors. The @Error doesn't catch it, just silently does nothing. If i use more that one value, It gives a "Dimension value exceeded" error. Anyone know where i messed up on these arrays?

EDIT: Yes, I'm the kind of coder that uses random variable names just to get the job done.

Edited by D-Generation X
Link to comment
Share on other sites

$ii[0][$i]

should be

$$ii[$i][0]

I think?

edit: actually......gimme a sec.....

#Include <GUIConstants.au3>
GLobal $ii, $listData = ""
FileWrite(@ScriptDir &"\Phonebook.ini", "")
$GUI = GUICreate("BeUrSelf Phone Thing") ; Displays a GUI that is... some width and height i guess
$List = GUICtrlCreateList("", 5, 5, 280, 300)
$Menu1 = GUICtrlCreateMenu("&Help")
$MPhoneBook = GUICtrlCreateMenuitem("How to use Phonebook", $Menu1)
$ButtonUpdate = GUICtrlCreateButton("Update Phone Book", 290, 10)
GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            Exit
        Case $MPhoneBook
            MsgBox(0, "How to use Phonebook", "Ok, there is a file called Phonebook.ini in your script directory"&@CR&"Take this file and fill out the phone book like this:"&@cr&"[phonebook]"&@cr&"1=Number"&@cr&"2=number"&@cr&" and so on. Then click the Update button. The phonebook shoud load")
        Case $ButtonUpdate
            GUICtrlSetData($List, "")
            $ii = IniReadSection(@ScriptDir &"\Phonebook.ini", "phonebook")
            For $i = 1 to $ii[0][0]
                $listData &= $ii[$i][0] & "|"
                GUICtrlSetData($List, $ii[$i][1])
                If @Error Then MsgBox(0, "", "You haven't set up a Phonebook yet!")
            Next
           
    EndSwitch
WEnd
Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

Then it just lists 1, 2, 3 instead of the number. Maybe i should have mentioned this:

Heres how the INI is set up

[phonebook]

1=17346675776

2=17345550999

3=17348675309

EDIT: MIssed your edit

Edited by D-Generation X
Link to comment
Share on other sites

#Include <GUIConstants.au3>
GLobal $ii, $listData = ""
FileWrite(@ScriptDir &"\Phonebook.ini", "")
$GUI = GUICreate("BeUrSelf Phone Thing") ; Displays a GUI that is... some width and height i guess
$List = GUICtrlCreateList("", 5, 5, 280, 300)
$Menu1 = GUICtrlCreateMenu("&Help")
$MPhoneBook = GUICtrlCreateMenuitem("How to use Phonebook", $Menu1)
$ButtonUpdate = GUICtrlCreateButton("Update Phone Book", 290, 10)
GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            Exit
        Case $MPhoneBook
            MsgBox(0, "How to use Phonebook", "Ok, there is a file called Phonebook.ini in your script directory"&@CR&"Take this file and fill out the phone book like this:"&@cr&"[phonebook]"&@cr&"1=Number"&@cr&"2=number"&@cr&" and so on. Then click the Update button. The phonebook shoud load")
        Case $ButtonUpdate
            GUICtrlSetData($List, "")
            $ii = IniReadSection(@ScriptDir &"\Phonebook.ini", "phonebook")
            For $i = 1 to $ii[0][0]
                $listData &= $ii[$i][0] & "|"
                GUICtrlSetData($List, $ii[$i][1])
                If @Error Then MsgBox(0, "", "You haven't set up a Phonebook yet!")
            Next
           
    EndSwitch
WEnd

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

turns IniReadSection is.....alphabetized? Why? And wouldn't it make sense for there to be a flag for that? Or at least put it in remarks?

Or is it already done in a newer version I'm not aware of? :P

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

turns IniReadSection is.....alphabetized? Why? And wouldn't it make sense for there to be a flag for that? Or at least put it in remarks?

Or is it already done in a newer version I'm not aware of? :P

What are you on about? Trying writing a complete and coherent sentence.

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...