Sign in to follow this  
Followers 0
layer

Non-Array variable?

9 posts in this topic

i get this error, whats wrong?:

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

Error: Subscript used with non-Array variable.

heres the full code:

HotKeySet("^!x", "MyExit")

while 1

$coord = PixelSearch(0, 0, 724, 556, 0xBD9E4A, 0, 30)

$coorda= PixelSearch(0, 0, 724, 556, 0x313018, 0, 25)

If Not @error Then

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

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

EndIf

wend

Func MyExit()

Exit

EndFunc

help plz!


FootbaG

Share this post


Link to post
Share on other sites



hehe, thank you, im sort of new, two weeks since i had it =D thank you larry!


FootbaG

Share this post


Link to post
Share on other sites

wait a sec, im still getting the same error, heres the new code:

HotKeySet("^!x", "MyExit")

while 1

$coord = PixelSearch(0, 0, 724, 556, 0xBD9E4A, 0, 30)

$coorda= PixelSearch(0, 0, 724, 556, 0x313018, 0, 25)

If Not @error Then

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

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

EndIf

if @error then

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

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

endif

wend

Func MyExit()

Exit

EndFunc

whats wrong now!?


FootbaG

Share this post


Link to post
Share on other sites

sry larry, i hate to bother you again =( but it still doesn't work, but when i get the error, it points to the "[0]" part, i don't know why, any other suggestions larry, thanks agaiN! =D


FootbaG

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Maybe this will help:

HotKeySet("^!x", "MyExit")

while 1
  $coord = PixelSearch(0, 0, 724, 556, 0xBD9E4A, 0, 30)
  $err = @error
  $coorda= PixelSearch(0, 0, 724, 556, 0x313018, 0, 25)
  If Not @error And Not $err Then
     msgbox(0,"",$coord)
     MouseClick ("left", $coord [0], $coord [1], 1, 0) 
     MouseClick ("left", $coorda [0], $coorda [1], 1, 0)
  Else
     MsgBox(0,"Not Found", "Pixel Was Not Found On Screen")
     ExitLoop
  EndIf
wend

Func MyExit()
  Exit 
EndFunc

The problem is your if logic still tries to access $coord and $coordA if they are NOT arrays.

*** Matt @ MPCS

Edited by Matt @ MPCS

Share this post


Link to post
Share on other sites

nice, it worked, but can i make it so that the loop keeps going, like if the pixel= not found then it will scan again?

thank you both larry and matt! =D


FootbaG

Share this post


Link to post
Share on other sites

This must be one of those too obvious solutions. :) Take out the ExitLoop after the else. You may also want to remove the MsgBox then also because it will show everytime the loop goes around.

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

yikes! thank you, sorry for the obvious questions, but now i know!

thanks again


FootbaG

Share this post


Link to post
Share on other sites

Just so you know, you should probably take out the else statement also if you remove the exitloop and msgbox lines. Glad I could be of service! :)

*** Matt @ MPCS

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  
Followers 0