PcExpert Posted March 16, 2009 Share Posted March 16, 2009 Hi all, I got some trouble with the following. I'll first post my code: Dim $docent_array[1] $docent_array = _FileListToArray("Docenten", "*.ini", 1) For $t = 0 To $docent_array[0] ReDim $docent_array[$docent_array[0]] Next $left = 45 For $u = 0 To 5 $top2 = 210 For $o = 1 To 5 $l = $u * 5 + $o ; If StringLen($docent_array[$l]) > 2 Then $dcCheckBox[$l] = GUICtrlCreateCheckbox("dc" & $l, $left, $top2, 50, 20) $count2 += 1 $top2 += 20 ;EndIf Next $left += 65 Next For $a = 1 To $count2 If $docent_array[$a] <> "" Then GUICtrlSetData($dcCheckBox[$a], $docent_array[$a]) EndIf Next As you see, its not the full code just the part this is about, I am getting errors about the array: 'Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If $docent_array[$a] <> "" Then If ^ ERROR' Its probably because of the subscripts, as you can see its currently 1. I thought to fix the error by redimming the array, But didnt get me much further. I know that the array contains information (tested with _ArrayDisplay()). Does somebody know how to solve this issue? Thank you! Link to comment Share on other sites More sharing options...
Authenticity Posted March 16, 2009 Share Posted March 16, 2009 I don't yet understand some parts of the code but I believe that these are the root of the problem: For $t = 0 To $docent_array[0] ReDim $docent_array[$docent_array[0]] Next I don't see the point why you're using this loop, and by the way it's ReDim $docent_array[$docent_array[0]+1] unless you want to resize it to one less than the original array size. Also, I think it's required to see if $count2 is bigger than $docent_array[0] before processing this loop. At last, you don't need to use declare $docent_array as an array, let _FileListToArray do that for you. -Just my notes. ;] Link to comment Share on other sites More sharing options...
PcExpert Posted March 16, 2009 Author Share Posted March 16, 2009 (edited) Thanks Authenticity. $count2 was much bigger than it should be, going to fix it:). Edited March 17, 2009 by PcExpert Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2009 Moderators Share Posted March 16, 2009 PcExpert,Hello again!The problem is that your $l loop is running from 1 to $u * 5 + $o which means 1 to 30. But your $docent_array could well be less than that. So as soon as $l is higher than the top value of $docent_array > error.You need to put another If to stop this:For $o = 1 To 5 $l = $u * 5 + $o If $l < $docent_array[0] + 1 Then ConsoleWrite("Here " & $l & @CRLF) If StringLen($docent_array[$l]) > 2 Then $dcCheckBox[$l] = GUICtrlCreateCheckbox("dc" & $l, $left, $top2, 100, 20) $count2 += 1 $top2 += 20 EndIf EndIf NextTry that and see if it works. You can definitely remove the entire ReDim looping stuff, by the way!M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PcExpert Posted March 16, 2009 Author Share Posted March 16, 2009 Melba, you're great! Thanks for noticing this so fast. All the problems have gone now . Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2009 Moderators Share Posted March 16, 2009 PcExpert, The first reply was from Authenticity - you might like to edit your post #3! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PcExpert Posted March 17, 2009 Author Share Posted March 17, 2009 (edited) Thanks for the suggestions Melba, I knew something was wrong with that post. FIXED! Sorry Authenticity Edited March 17, 2009 by PcExpert 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