Jat421 Posted May 27, 2014 Share Posted May 27, 2014 (edited) Hello, I am trying to change a script to take menu items from an ini file and having some issues $aArray = IniReadSection("test.ini","test") If not @error Then For $i = 1 To $aArray[0][0] MsgBox("Test","", "Key: " & $aArray[$i][0] & @CRLF & "Value: " & $aArray[$i][1]) Next EndIf And I am trying to use the read ini file in the array but getting error Array variable has incorrect number of subscripts or subscript dimension range exceeded.: Here is where I am trying to use the array in GUI $Item1 = GUICtrlCreateMenuItem($aArray[$i][1],$Menu) $item1 is later used in an while loop to check what is selected from the menu. Edited May 27, 2014 by Jat421 Link to comment Share on other sites More sharing options...
possy_99 Posted May 27, 2014 Share Posted May 27, 2014 try changing For $i = 1 To $aArray[0][0] to For $i = 1 To $aArray[0] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 27, 2014 Moderators Share Posted May 27, 2014 possy_99,From the Help file for IniReadSection: Return ValueSuccess: a 2 dimensional arraySo your suggestion to use 1D array syntax is completely nonsensical. Jat421,Can you post an example of the ini file you are using, as I can see nothing wrong with the code as posted. 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...
Valuater Posted May 27, 2014 Share Posted May 27, 2014 try this... For $i = 1 To $aArray[0][0] -1 If I remember correctly 8) Link to comment Share on other sites More sharing options...
Jat421 Posted May 27, 2014 Author Share Posted May 27, 2014 Here is the ini file. [test] key1=value1 key2=value2 key3=value3 Also the -1 actually did the trick but I am trying to hold more keys into the array and would like to call them later in the script. How can the expand the array to hold more data I tried $aArray[2][2] but that throws an error? Thanks guys for all the help! $Item2 = GUICtrlCreateMenuItem($aArray[$i][3],$Menu) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 27, 2014 Moderators Share Posted May 27, 2014 Jat421m,Using the "- 1" will leave you one key/value short - try it and see:$aArray = IniReadSection("test.ini", "test") If Not @error Then For $i = 1 To $aArray[0][0] - 1 ConsoleWrite("Key: " & $aArray[$i][0] & @CRLF & "Value: " & $aArray[$i][1] & @CRLF) Next ConsoleWrite(@CRLF) For $i = 1 To $aArray[0][0] ConsoleWrite("Key: " & $aArray[$i][0] & @CRLF & "Value: " & $aArray[$i][1] & @CRLF) Next EndIfYou only need the "- 1" if you use UBound to get the count - here the function returns the count in the [0][0] element. To expand the array, use ReDim to resize it like this:#include <Array.au3> ; only to see the result $aArray = IniReadSection("test.ini", "test") ; Add a column ReDim $aArray[$aArray[0][0] + 1][3] ; [same number of rows][add a column] ; And see the result _ArrayDisplay($aArray, "", Default, 8)All clear? 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...
possy_99 Posted May 27, 2014 Share Posted May 27, 2014 (edited) sincere apologies for the mis-information.. I didn't really have my brain in gear and just did a quick google search, which lead me to the autoitwiki with example scripts as shown.. guess I should have looked harder Edited May 27, 2014 by possy_99 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 27, 2014 Moderators Share Posted May 27, 2014 possy_99,No problem - can happen to us all. M23 possy_99 1 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...
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