Jump to content

Recommended Posts

Posted

Hello everyone,

I have programmed a bot using autoit, everything is fine, but occasionally (one time in 6 hours) I get the message " Line -1; Error:Subscript used with non-Array variable ". And then everything stops, I know that it means that the pixelsearch returns @error instead of array, but I want to know why it happens rarely?

Posted (edited)

Hello everyone,

I have programmed a bot using autoit, everything is fine, but occasionally (one time in 6 hours) I get the message " Line -1; Error:Subscript used with non-Array variable ". And then everything stops, I know that it means that the pixelsearch returns @error instead of array, but I want to know why it happens rarely?

That error happens anytime you reference an array but exceed the number of indices that it's been declared for.

You can see an example of this using this little script:

$split = StringSplit ("This, is a string", ",")
MsgBox (0, "", $split[5])

If you run the script from SciTE you should see the error pop up in the bottom pane. This is because Stringsplit made you an array of:

$split[0]=3
$split[1]=This
$split[2]= is a string

and we tried to reference a # greater than 3.

You're most likely going to run your bot from SciTE so the output can capture what line of your script is having the problem. That, or go through your script and anywhere that you create an array, do error checking (like using ubound or checking @error if you're using a function) to make sure that it worked instead of just blindly calling an array element.

Edited by exodius

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