Sign in to follow this  
Followers 0
Jdop

How to debug the infamous Line -1 "array variable has incorrect number of subscripts" error

7 posts in this topic

I have a program that is randomly getting this error (it loads data from a webpage). It works 99% of the time, but someting is triggering the array bounds error.

I would be glad to try and debug this, or intercept the error before it crashed the script, but this error message is not helpful and it appears to be internal to autoit (not in any of the includes) , so I cant insert debug code where the error originates.

Any ideas?

Share this post


Link to post
Share on other sites



I have a program that is randomly getting this error (it loads data from a webpage). It works 99% of the time, but someting is triggering the array bounds error.

I would be glad to try and debug this, or intercept the error before it crashed the script, but this error message is not helpful and it appears to be internal to autoit (not in any of the includes) , so I cant insert debug code where the error originates.

Any ideas?

Apart from what Mast3rpyrO has already said, before you use the variable check that it is an array with IsArray, and when you increment the index make sure you don't go beyond Ubound($Array).

You can insert debug code where the error occurs, or before it, I think you are misunderstanding something there.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Apart from what Mast3rpyrO has already said, before you use the variable check that it is an array with IsArray, and when you increment the index make sure you don't go beyond Ubound($Array).

You can insert debug code where the error occurs, or before it, I think you are misunderstanding something there.

No , I understand. The problem I 'm referring to is the fact that the error message gives no indication of any kind WHERE in my code the problem is. I have array functions in a number of places.

Yes, I could put debug code in every possible spot, but that's rather inelegant.

Is there some reason AI cant report the line number or calling routine in the error message? I am running compiled code most of the time fyi.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I am running compiled code most of the time fyi.

And that is why the line is reported as -1.

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@Jdop - You do know about the @Compiled macro, don't you? You could use it like this in your script:

If @Compiled Then
...
Else
...
EndIf

Debugging some things about a script, you need a compiled version of it, but not as soon in the development process as you do when you don't use the @Compiled macro.

Edited by Squirrely1

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

I ran the same code from source, and was able to reproduce the error and get a line number. The 'rare' nature of the problem made it tricky to catch.

I imagine it would be possible for AutoIt to output a more informative error message from the compiled version, but possibly at a cost of bloating the code, I don't know.

If there isn't an option to compile with line numbers, maybe there should be.

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