Jump to content

Overflow array - (Moved)


Recommended Posts

Local $x[3] = [2,5,8];

ConsoleWrite($x[0]&@CRLF)

ConsoleWrite($x[1]&@CRLF)

ConsoleWrite($x[2]&@CRLF)

ConsoleWrite($x[3]&@CRLF);here... the code return ^ERROR and the program finish inmediatly

ConsoleWrite("This is finished"&@CRLF)

 

Excuse me if not the right place to ask the question but I have the following question:
How can I avoid the error of autoit (^ ERROR) Do not abruptly end my program ... how to make a try catch block to follow the next line.

Link to comment
Share on other sites

its kind of simple don't reference variables that don't exist and use error checking in your code otherwise its like writing ConsoleWrite($var + 1 & @CRLF) without actually declaring $var.  For example:

Local $aArray[] = [9,3,7,2,0,8]
If IsArray($aArray) Then
    For $i = 0 To UBound($aArray) - 1
        ConsoleWrite($aArray[$i] & @CRLF)
    Next
EndIf

 

Link to comment
Share on other sites

This error, 
"......au3" (9) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
ConsoleWrite($x[3]&@CRLF)
ConsoleWrite(^ ERROR      ", 
is displayed in the output pane of SciTE when the .au3 script is run. 

Do not try to access an element in the array that does not exist.

Either increase the number of elements in the definition, change "Local $x[3]" to "Local $x[4]"; or,
Do not use an array index number that exceeds the number of elements in the array. e.g. "Local $x[3]", this array has 3 elements, $x[0], $x[1], and $x[2] - 3 elements.
See/Find: The array always starts at index zero.
 

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