Sign in to follow this  
Followers 0
Suppish

array variable has incorrect number of subscripts

3 posts in this topic

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.
 
 
 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

 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.

Share this post


Link to post
Share on other sites

Thanks,

I see what I've been doing wrong now. It seems that when everything returned false, it just instantly cranked $CurrentInstall to overflow.

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