Jump to content

Select random letter from an array


jonnyno
 Share

Recommended Posts

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