Fload 0 Posted September 16, 2011 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 98 Posted September 16, 2011 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 0 Posted September 16, 2011 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 5 Posted September 16, 2011 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 . Try with the above you may not face the previous error. 1 Fload reacted to this Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font] Share this post Link to post Share on other sites