Jump to content
Sign in to follow this  
Fload

Help with Array errors

Recommended Posts

Fload

having trouble with a function i wrote, im fairly new to programming...

First call of this function works fine however if i call it again i get this error....

C:\Program Files\AutoIt3\Include\PKtools.au3 (80) : ==> Subscript used with non-Array variable.:

MouseClick ( "left" ,$coord[0] ,$coord[1])

MouseClick ( "left" ,$coord^ ERROR

Func Check() ;Checks For Color does action according to result
  Local $coord[3]
  Local $var2 = "0x57C522" ;Color to check

  $coord = PixelSearch (404,507,406,509, $var2,20) ; Check for color
  If @error <> 1 Then
  Sleep(10)
  Else
  $coord = PixelSearch(450,226,570,346, "0x6CC462" ,10) ;find item
   MouseClick ( "left" ,$coord[0] ,$coord[1]) ;click item
   sleep(3000)
   MenuSelect("Flo")
   sleep(3000)
   MenuSelect("He")
  EndIf
EndFunc

Share this post


Link to post
Share on other sites
AdamUL

Your not error checking your second PixelSearch which re-declares $coord. If the function throws an error $coord = 0, a non-array variable, which is the error it is throwing.

Adam

Share this post


Link to post
Share on other sites
Fload

the only thing i dont understand is that i know that color is there... why would it throw an error?

Share this post


Link to post
Share on other sites
Syed23

Hmm... Have something like this before you handle some arrays..so you can avaoid errors mostly..

If IsArray($coord) Then
  MouseClick ( "left" ,$coord[0] ,$coord[1]) ;click item
  Else
    MouseClick ( "left" ,$coord) ;click item
 EndIf

Note: i gave this option since i don't know complete picture of your program :graduated: . Try with the above you may not face the previous error.

  • Like 1

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.