Sign in to follow this  
Followers 0
davecentaur

array variable dimension range exceeded error

5 posts in this topic

#1 ·  Posted (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 by davecentaur

Share this post


Link to post
Share on other sites



 

IniReadSection returns a 2 dimensional array...

MsgBox ($MB_SYSTEMMODAL, "", $MyArray[$i][row number here])

Thanks I'll ajdust my script

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

 

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0