Jump to content

Recommended Posts

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
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.

Posted

 

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...