NELyon Posted December 12, 2006 Posted December 12, 2006 (edited) 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 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 December 12, 2006 by D-Generation X
theguy0000 Posted December 13, 2006 Posted December 13, 2006 (edited) $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 December 13, 2006 by theguy0000 The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
NELyon Posted December 13, 2006 Author Posted December 13, 2006 (edited) 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 December 13, 2006 by D-Generation X
theguy0000 Posted December 13, 2006 Posted December 13, 2006 #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
NELyon Posted December 13, 2006 Author Posted December 13, 2006 AGH YOU ARE MY HERO!!!!! [/personal joke]
theguy0000 Posted December 13, 2006 Posted December 13, 2006 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? The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
Valik Posted December 13, 2006 Posted December 13, 2006 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? What are you on about? Trying writing a complete and coherent sentence.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now