jonnyno Posted September 17, 2011 Posted September 17, 2011 (edited) Hello guys, im trying to make a script that press a random letter inside an established array. Local $Array[5] = ['a', 'd', 'c', 'm', 'l'] Local $String Local $deck While 1 $Name = "" For $x = 1 to 2; length or name (could also be random) $y = Random(1, 62, 1) Switch $y Case 1 to 10 send("{a down}") Sleep(35) Case 11 to 36 send("{d down}") Sleep(45) Case 37 to 62 ;send(Chr($y + 60)); $deck = Random(0, UBound($Array), 1) if $deck >=0 then ; (have tryed to avoid the error with this if, if $deck is not a number should skip, doest work) $String = $Array[$deck] ;<----ERROR LINE send($String) Else $String = $Array[0] send($String) Endif Sleep(90) EndSwitch Next sleep(800) Wend It works till i recieve an error on the line 25 ######################################################################### $String= $Array[$deck] $String= ^ ERROR Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. ########################################################################## Thanks in advance Joy Edited September 17, 2011 by jonnyno
JoHanatCent Posted September 18, 2011 Posted September 18, 2011 Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. ########################################################################## Thanks in advance Joy The answer from UBound($Array) would be 5. You want from 0 to four. So change this bit: $deck = Random(0, UBound($Array) - 1, 1)
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