zzz Posted April 5, 2009 Posted April 5, 2009 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?
exodius Posted April 5, 2009 Posted April 5, 2009 (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 April 5, 2009 by exodius
KaFu Posted April 5, 2009 Posted April 5, 2009 Or use isarray() to check array for validity. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now