Jump to content

array variable has incorrect number of subscripts


Recommended Posts

Been fumbling around with arrays and this error has popped up. However, the array behaves rather strangely as I will describe later.

Currently working on an automated installer, so users basically pick from a list of programs via checklist and select what they want to install.

The array is defined as follows

local $App[25]

$App[0] = ""
$App[1] = GUICtrlCreateCheckbox($AppName[1], 20, 40, 270, 25)
$App[2] = GUICtrlCreateCheckbox($AppName[2], 20, 65, 270, 25)
GUICtrlSetState($App[02], $GUI_DISABLE)
....
$App[24] = GUICtrlCreateCheckbox($AppName[2], 20, 65, 270, 25)
GUICtrlSetState($App[24], $GUI_DISABLE)
 
And it goes on to fill the array.
 
The error I've been getting occurs in this line of code:
 
$CurrentInstall = $CurrentInstall + 1
if GUICtrlRead($App[$CurrentInstall]) == $GUI_CHECKED Then
      ;Do something
endif
 
However, this error seems to be behaving rather strangely. The error only occurs whenever the checkboxes are unchecked. When the checkboxes are checked, they go on to do whatever they are suppose to do and install the respective highlighted programs.
 
Thanks for any help I can get on the matter.
 
 
 

 

Link to comment
Share on other sites

 That error occurs when you use a subscript that is out of range of your array...subscript > Ubound($array)-1

; you need to exit your loop, properly
For $i = 0 To UBound($App)-1
    if GUICtrlRead($App[$i]) == $GUI_CHECKED Then
        ;Do something
    endif
Next
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
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
 Share

  • Recently Browsing   0 members

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