Sign in to follow this  
Followers 0
bald1

Quick question, once again!

24 posts in this topic

.....au3 (53) : ==> Subscript used with non-Array variable.:

MouseMove($coord1[0], $coord1[1], 1)

MouseMove($coord1^ ERROR

What does this error code mean?

THanks in advance gents :D

Share this post


Link to post
Share on other sites



Perhaps you should try reading it. It usually works for me.

Lets see, it says "Subscript used with non-Array variable" which obviously means that $coord1 isn't an array.


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

Perhaps you should try reading it. It usually works for me.

Lets see, it says "Subscript used with non-Array variable" which obviously means that $coord1 isn't an array.

Surely im making some very basic mistake here that only noobs would do. That's cool im a noob. Next time ill make sure to make that apparent in the first few lines of the post, so as to not warrant and bother u with making arrogant responses :D

I suppose the question i should have been asking is, why would autoit want it to be an array, I dont need it to be. I realize that $coord, which not surprisingly is a return from a pixelsearch function is returned in an array. So then, how do i get rid of this annoy error message :D

Share this post


Link to post
Share on other sites

If $coord1 is returned from pixelsearch and isn't an array then pixelsearch had an error. According to the helpfile the only reason pixelsearch would fail is if the color isn't found. Use the autoit window info tool to make sure your searching for the right color.


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

Yeah, I thought so too, but the script runs just fine. Detects, targets and exits as it's supposed to, yet that error occurs.

I tried doing

Local $coord1[2] = [0, 0]

in the beginning of the script with no effect. Makes my face hurt :D

Share this post


Link to post
Share on other sites

Could you post all the relevant parts of the script? Without that I can only help you with what you tell me, and while it may be true that the script runs just fine, that doesn't do much to help fix it.


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

Local $coord1 = PixelSearch(0 + $vSearchCoords1, 0 + $vSearchCoords2, 0 + $vSearchCoords3, 0 + $vSearchCoords4, $aPixel[0], 3, 1)
$var = $var * 0
        Sleep(200)
        If not @error Then
            MouseMove($coord1[0], $coord1[1], 1)
            Sleep(500)
            $coordbox1 = $coord1[0] - 50

            $coordbox2 = $coord1[1] - 50

            $coordbox3 = $coord1[0] + 75

            $coordbox4 = $coord1[1] + 100

This is all that should be relevant, thank u for taking some time to help me out :D

Share this post


Link to post
Share on other sites

Well, "$var = $var * 0" is pretty pointless, why not just use "$var = 0"? But you shouldn't still be getting the error because of the "If Not @error Then".


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

Well, "$var = $var * 0" is pretty pointless, why not just use "$var = 0"? But you shouldn't still be getting the error because of the "If Not @error Then".

Please explain that in more detail. How would checking the error value for the Sleep() help against a possible failure in the PixelSearch()? :D

Share this post


Link to post
Share on other sites

Now I feel like slapping myself. Can't believe I missed that.:D

@bald1

You would want to move sleep(200) somewhere else, probably before you declare $coord1. As AdmiralAlkex pointed out, the @error is checking the error of sleep(200), and so it is reset to 0 from whatever it was set to by pixelsearch.


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

There are a couple of things wrong there. First off anything multiplied by 0 ($var = $var * 0) is still 0.

Next we come to the

Sleep(200)
    If not @error Then

Sleep (200) tells the script to pause for 200 milliseconds. There is no ifs ands or errors about it. Where in your careful study of the help file did it suggest that Sleep() returned an error? How do you think Sleep() could fail thus necessitating an error return?


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
:D Now I want to slap myself again. I guess it didn't matter that you had the sleep(200) there.

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

And what's the deal with the four "0 + somevariable" anyway? Looks like bald1 has an addiction with zeroes! :D

Edit:Or maybe his addiction is with pointless mathematical operations? :D

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

Hm, i remember i used some function in the beginning which kept erroring out, until i did a 0 + $var, but i suppose that wasnt pixcelsearch func..

Also, i saw the $var = $var * 0 being used somewhere in an example. - It's not my fault! I thought u were only able to declare and scope $vars once, after that replying on "$var = $var something" solutions to change it :D

Never thought i'd learn this much from a tiny piece of script, but what i really asked about seems to have not been figured out yet?

O and

Edit:Or maybe his addiction is with pointless mathematical operations? :D

Perhaps i do!

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Maybe some useful inside information: The value of @error is reset to 0 every time the interpreter enters a new function. you call a native AutoIt function.

Edited by Manadar

Share this post


Link to post
Share on other sites

As Geosoft and Manadar said

Here is the right order of used commands:

$var = $var * 0
Local $coord1 = PixelSearch(0 + $vSearchCoords1, 0 + $vSearchCoords2, 0 + $vSearchCoords3, 0 + $vSearchCoords4, $aPixel[0], 3, 1)
If Not @error Then
 Sleep(200)
 MouseMove($coord1[0], $coord1[1], 1)
 Sleep(500)
 $coordbox1 = $coord1[0] - 50
 $coordbox2 = $coord1[1] - 50
 $coordbox3 = $coord1[0] + 75
 $coordbox4 = $coord1[1] + 100
...

Share this post


Link to post
Share on other sites

That does change the logic a little. If it errors out, then the sleep is never performed.

$var = $var * 0
Local $coord1 = PixelSearch(0 + $vSearchCoords1, 0 + $vSearchCoords2, 0 + $vSearchCoords3, 0 + $vSearchCoords4, $aPixel[0], 3, 1)
If Not @error Then
 Sleep(200)
 MouseMove($coord1[0], $coord1[1], 1)
 Sleep(500)
 $coordbox1 = $coord1[0] - 50
 $coordbox2 = $coord1[1] - 50
 $coordbox3 = $coord1[0] + 75
 $coordbox4 = $coord1[1] + 100
...
Else
  Sleep(200)
EndIf

Share this post


Link to post
Share on other sites

I appreciate the much needed wisdom that is bestowed upon me!

aand just to be completely sure: sleep() = nativ function, thus resetting the @error flag to 0, correct? Im not yet at my stationary to check if it works :D

Thanks!

Share this post


Link to post
Share on other sites

SetError(1) ; sets @error to 1
Sleep(0) ; sets @error to 0
MsgBox(0, "", @error)

Pops up 0.

Actually all functions reset @error.

SetError(1) ; sets @error to 1
Sleeper() ; sets @error to 0
MsgBox(0, "", @error)

Func Sleeper()
EndFunc

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