davecentaur Posted March 10, 2015 Posted March 10, 2015 (edited) I'm fairly new to autoit and I'm having issues with reading from my array. My scripts is basically as follows: $MyArray = IniReadSection ("Someini.ini" , "iniSection") $NoElements = UBound($MyArray) $i=1 For $i = 1 to $NoElements-1 MsgBox ($MB_SYSTEMMODAL, "", $MyArray[$i]) Next The $NoElements variable returns the correct number of elements in the array (+1) however when I try to display the values in a message box I get the range exceeded error. I tested the _FileWriteFromArray after I created the array so I know its not empty. Can someone point out where I'm going wrong. Edited March 10, 2015 by davecentaur
JohnOne Posted March 10, 2015 Posted March 10, 2015 IniReadSection returns a 2 dimensional array... MsgBox ($MB_SYSTEMMODAL, "", $MyArray[$i][row number here]) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
davecentaur Posted March 10, 2015 Author Posted March 10, 2015 IniReadSection returns a 2 dimensional array... MsgBox ($MB_SYSTEMMODAL, "", $MyArray[$i][row number here]) Thanks I'll ajdust my script
JohnOne Posted March 10, 2015 Posted March 10, 2015 (edited) While we're here. ; Think about error checking $MyArray = IniReadSection("Someini.ini", "iniSection") If @error Then Exit MsgBox(0, "Error", "IniReadSection Failed") EndIf ; Below is fine, but you are making an unecessary call to Ubound as array[0][0] holds the index count ;$NoElements = UBound($MyArray) $NoElements = $MyArray[0][0] ;It is not needed to declare the iterator in a for next loop, I doubt even must delare vars would cry about it ;$i=1 For $i = 1 To $NoElements MsgBox($MB_SYSTEMMODAL, "", $MyArray[$i][0] & " = " & $MyArray[$i][1]) Next Edited March 10, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
davecentaur Posted March 10, 2015 Author Posted March 10, 2015 While we're here. ; Think about error checking $MyArray = IniReadSection("Someini.ini", "iniSection") If @error Then Exit MsgBox(0, "Error", "IniReadSection Failed") EndIf ; Below is fine, but you are making an unecessary call to Ubound as array[0][0] holds the index count ;$NoElements = UBound($MyArray) $NoElements = $MyArray[0][0] ;It is not needed to declare the iterator in a for next loop, I doubt even must delare vars would cry about it ;$i=1 For $i = 1 To $NoElements MsgBox($MB_SYSTEMMODAL, "", $MyArray[$i][0] & " = " & $MyArray[$i][1]) Next Thanks very much for your help. It works a treat.
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