PcExpert Posted June 17, 2008 Share Posted June 17, 2008 Hi all, I'm making a diary script. But when I try to add all the sections found in the specified ini to the listview i'm getting errors like Digital Diary.au3 (28) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: For $r = 1 To $readdates[0][0] For $r = 1 To ^ ERROR This is my current code: #include <GUIConstants.au3> #Include <GuiListView.au3> GUICreate("Digital Diary", 500, 400) ; will create a dialog box that when displayed is centered $List = GUICtrlCreateList("", 5, 5, 150, 375) $Edit = GUICtrlCreateEdit("", 170, 5, 325, 375) GUISetState () ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed $readdates = IniReadSectionNames("diary.ini") If $readdates = @error Then MsgBox(16, "Digital Diary", "Geen data gevonden.") Else If IsArray($readdates) Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($List)) For $r = 1 To $readdates[0][0] GUICtrlCreateListViewItem($readdates[$r][1], $List) Next EndIf EndIf While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect Wend Could somebody please help me out, I tried different things, like removing a '[0]' and such things, but no luck . Thanks! Link to comment Share on other sites More sharing options...
Kiti Posted June 17, 2008 Share Posted June 17, 2008 Digital Diary.au3 (28) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: For $r = 1 To $readdates[0][0] For $r = 1 To ^ ERROR That error usually appears when the second value is less than the first. This means your "IniReadSectionNames" don't get any result. Try a msgbox with $readdates to make sure this is the problem. Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
PcExpert Posted June 17, 2008 Author Share Posted June 17, 2008 By editing the for loop to this: For $r = 1 To $readdates[0] MsgBox(0, "", $readdates[$r]) ;GUICtrlCreateListViewItem($readdates[$r], $List) Next the MSGbox shows the right dates, but I cant manage to add them to the listview. Link to comment Share on other sites More sharing options...
PcExpert Posted June 17, 2008 Author Share Posted June 17, 2008 Since my last post i've been trying to see if it helped to change values, but it didnt. I also tried to have a single '[0]' instead of a double. But still no luck. Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 17, 2008 Share Posted June 17, 2008 Hi all, I'm making a diary script. But when I try to add all the sections found in the specified ini to the listview i'm getting errors like This is my current code: #include <GUIConstants.au3> #Include <GuiListView.au3> GUICreate("Digital Diary", 500, 400); will create a dialog box that when displayed is centered $List = GUICtrlCreateList("", 5, 5, 150, 375) $Edit = GUICtrlCreateEdit("", 170, 5, 325, 375) GUISetState () ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed $readdates = IniReadSectionNames("diary.ini") If $readdates = @error Then MsgBox(16, "Digital Diary", "Geen data gevonden.") Else If IsArray($readdates) Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($List)) For $r = 1 To $readdates[0][0] GUICtrlCreateListViewItem($readdates[$r][1], $List) Next EndIf EndIf While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect Wend Could somebody please help me out, I tried different things, like removing a '[0]' and such things, but no luck . Thanks! Just fix your error handling and use the right array type: $readdates = IniReadSectionNames("diary.ini"); returns section names in a 1D array If @error Then MsgBox(16, "Digital Diary", "Geen data gevonden.") Else If IsArray($readdates) Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($List)) For $r = 1 To $readdates[0] GUICtrlCreateListViewItem($readdates[$r], $List) Next EndIf EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 17, 2008 Share Posted June 17, 2008 That error usually appears when the second value is less than the first. This means your "IniReadSectionNames" don't get any result. Try a msgbox with $readdates to make sure this is the problem. That condition does not produce an error, it only stops any execution of the loop: $x = 3 For $n = $x To 2 MsgBox(16, "Failure", "This message never seen.") Next MsgBox(64, "Done", "Done") Where you have arrays with the count in [0] (or [0][0] also), it is OK to use this: For $n = 1 To $avArray[0] ; ... Next This will not give an error if $avArray[0] = 0, it will just not execute the loop. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
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