Help - Search - Members - Calendar
Full Version: newbie need help on mistake
AC Tools Everything Macro > AC Tool > AC Tool Discussion
nijack
Procedure checkcolor
LoadRGB $mouse
IF {RGBRed} = 167 and {RGBGreen} = 255 and {RGBBlue} = 255
delay 1000
LeftClick
Stop
end
loop 10000
delay 600000
loop 2
MousePos 279, 752
delay 500
leftclick
delay 500
MousePos 762, 140
delay 500
call checkcolor
MousePos 396, 749
delay 500
leftclick
delay 500
MousePos 810, 171
call checkcolor
MousePos 496, 757
delay 500
leftclick
delay 500
MousePos 862, 198
call checkcolor
MousePos 592, 761
delay 500
leftclick
delay 500
MousePos 909, 224
call checkcolor
MousePos 682, 757
delay 500
leftclick
delay 500
MousePos 960, 256
call checkcolor
End
end

it come out error,"could not find an END statement for all procedure",how to solve it?
how to setting the "alt + ~" (it is combined hotkey)
if got any other better method of coding please tell me too...newbie in the stage of learning..
Triane
Use indentation to identify structures.

If you don't know how this is done, look on the "Editor" menu, and click, "Beautify Macro".

Doing that on your procedure produces:
CODE
Procedure checkcolor
  LoadRGB $mouse
  IF {RGBRed} = 167 and {RGBGreen} = 255 and {RGBBlue} = 255
    delay 1000
    LeftClick
    Stop
  end
  loop 10000
    delay 600000
    loop 2
      MousePos 279, 752
      delay 500
      leftclick
      delay 500
      MousePos 762, 140
      delay 500
      call checkcolor
      MousePos 396, 749
      delay 500
      leftclick
      delay 500
      MousePos 810, 171
      call checkcolor
      MousePos 496, 757
      delay 500
      leftclick
      delay 500
      MousePos 862, 198
      call checkcolor
      MousePos 592, 761
      delay 500
      leftclick
      delay 500
      MousePos 909, 224
      call checkcolor
      MousePos 682, 757
      delay 500
      leftclick
      delay 500
      MousePos 960, 256
      call checkcolor
    end
  end

...which clearly shows you are one "end" short of a set. I'm not going to look too closely at it, but on a cursory glance, I think you just need to add one more "end" at the bottom.

-Triane
nijack
erm,it happen the same question back to the topic,
"could not find an END statement for all procedure"

i tried to put "end" (2 or three of "end" apply),but it still like that.
//spelling mistake,i change from "tree" to "three"...pressed too fast and i always ignore the red line under the words)

also the second question, how to set the macro in game key in the (combined hotkey) "alt + ~", "alt + a" (it is combined hotkey in game)???
DaMOB
QUOTE(nijack @ Aug 7 2009, 08:48 AM) *
erm,it happen the same question back to the topic,
"could not find an END statement for all procedure"

i tried to put "end" (2 or tree of "end" apply),but it still like that.

also the second question, how to set the macro in game key in the (combined hotkey) "alt + ~", "alt + a" (it is combined hotkey in game)???

Now do you see what I said about these forums Triane? dry.gif
Triane
QUOTE(DaMOB @ Aug 7 2009, 10:45 AM) *
Now do you see what I said about these forums Triane? dry.gif

rofl -- indeed, although it doesn't seem that much more eggregious than many of the questions Ipa used to upbraid so eloquently -- perhaps it's just a lack of quality posts to dilute the stream that makes it seem worse biggrin.gif

QUOTE(nijack @ Aug 7 2009, 08:48 AM) *
i tried to put "end" (2 or tree of "end" apply),but it still like that.

Did you take my suggestion of running the "Beautify Macro" routine? If you did, it should, by virtue of the indentation, show pretty clearly where your missing "end" statement(s) are. Given the one procedure you illustrated, I'd surmise that perhaps you've been leaving "end" statements off of each of your procedures, thereby potentially leaving you many "ends" short over the entire script. Indentation and formatting your code is more than just making it beautiful, it's an aid against problems of this exact nature!

-Triane

Edit: OMG -- rofl, I just actually looked at that code, it's a disaster! (hint: unintended recursion is a very bad thing!) Nevertheless, assuming that you, in fact, want to put an "end" statement before the "loop 10000" line, it would eliminate some significant problems... also: is "loop 10000" really the way you want to contain the main portion of your program? given that the first thing it does is wait 10 minutes, I would assume "while 1=1" would work just as well, and not run the risk of expiring (although I WOULD be surprised if that code ran successfully for 100k minutes without SOMETHING crashing...)
nijack
huh,
thanks...but still blur at a lot of points....
does it is because of my "Procedure" line 1 to line 7 got the problem?

for
QUOTE
If you did, it should, by virtue of the indentation, show pretty clearly where your missing "end" statement(s) are.
i admit i doesn't try on beautiful macro...but i just tried a stupid step....

QUOTE

Procedure checkcolor
LoadRGB $mouse
IF {RGBRed} = 167 and {RGBGreen} = 255 and {RGBBlue} = 255
delay 1000
LeftClick
Stop
end
loop 10000
delay 600000
loop 2
MousePos 279, 752
delay 500
leftclick
delay 500
MousePos 762, 140
delay 500
call checkcolor end //change made
MousePos 396, 749
delay 500
leftclick
delay 500
MousePos 810, 171
call checkcolor end //change made
MousePos 496, 757
delay 500
leftclick
delay 500
MousePos 862, 198
call checkcolor end //change made
MousePos 592, 761
delay 500
leftclick
delay 500
MousePos 909, 224
call checkcolor end //change made
MousePos 682, 757
delay 500
leftclick
delay 500
MousePos 960, 256
call checkcolor END //change made
end
end


the error still "could not find an END statement for all procedure".
after i tried cutting the last line (end), another error occur "you are missing at least on end statement"

haha,it is funny.
can give me some 1-2 example (right) for me to settle the error?
erm,enjoying solute the error now,just like to find out the true of a mystery.
DaMOB
QUOTE(nijack @ Aug 7 2009, 03:01 PM) *
huh,
thanks...but still blur at a lot of points....
does it is because of my "Procedure" line 1 to line 7 got the problem?

for
QUOTE
If you did, it should, by virtue of the indentation, show pretty clearly where your missing "end" statement(s) are.
i admit i doesn't try on beautiful macro...but i just tried a stupid step....

QUOTE

Procedure checkcolor
LoadRGB $mouse
IF {RGBRed} = 167 and {RGBGreen} = 255 and {RGBBlue} = 255
delay 1000
LeftClick
Stop
end
loop 10000
delay 600000
loop 2
MousePos 279, 752
delay 500
leftclick
delay 500
MousePos 762, 140
delay 500
call checkcolor end //change made
MousePos 396, 749
delay 500
leftclick
delay 500
MousePos 810, 171
call checkcolor end //change made
MousePos 496, 757
delay 500
leftclick
delay 500
MousePos 862, 198
call checkcolor end //change made
MousePos 592, 761
delay 500
leftclick
delay 500
MousePos 909, 224
call checkcolor end //change made
MousePos 682, 757
delay 500
leftclick
delay 500
MousePos 960, 256
call checkcolor END //change made
end
end
the error still "could not find an END statement for all procedure".
after i tried cutting the last line (end), another error occur "you are missing at least on end statement"

haha,it is funny.
can give me some 1-2 example (right) for me to settle the error?
erm,enjoying solute the error now,just like to find out the true of a mystery.

First things first, and this is before anyone attempts to help you with your "END" statement problem, and that is you have to get rid of that recursion bug. I saw it and Triane finally saw it and I will tell you that you had better see it or your program is doomed to utter failure and the lack of a closing "END" statement is the least of your worries.

Do you happen to know what recursion is?
Triane
QUOTE(DaMOB @ Aug 7 2009, 04:24 PM) *
First things first, and this is before anyone attempts to help you with your "END" statement problem, and that is you have to get rid of that recursion bug. I saw it and Triane finally saw it and I will tell you that you had better see it or your program is doomed to utter failure and the lack of a closing "END" statement is the least of your worries.

Do you happen to know what recursion is?

Actually, that was my first knee-jerk response too (as indicated by my post), but afterwards I realised that if you look at the code between the "loop 10000" and its associated "end" statement as the "mainline" of the program, and the procedure as being only the code up to the "loop 10000" statement, then there isn't a recursion bug, and I suspect that's where the missing "end" should be placed...

Adding additional "end" statements to the bottom of the macro results in the recursion bug, and that's why (I think) he's getting errors that aren't indicating the actual problem clearly when he tries that.

i.e. this is what I think he intended:
CODE
Procedure checkcolor
  LoadRGB $mouse
  IF {RGBRed} = 167 and {RGBGreen} = 255 and {RGBBlue} = 255
    delay 1000
    LeftClick
    Stop
  end
end

// mainline
loop 10000
  delay 600000
  loop 2
    MousePos 279, 752
    delay 500
    leftclick
    delay 500
    MousePos 762, 140
    delay 500
    call checkcolor
    MousePos 396, 749
    delay 500
    leftclick
    delay 500
    MousePos 810, 171
    call checkcolor
    MousePos 496, 757
    delay 500
    leftclick
    delay 500
    MousePos 862, 198
    call checkcolor
    MousePos 592, 761
    delay 500
    leftclick
    delay 500
    MousePos 909, 224
    call checkcolor
    MousePos 682, 757
    delay 500
    leftclick
    delay 500
    MousePos 960, 256
    call checkcolor
  end
end

...personally, I think it should be something like:
CODE
constants
  result = true
end

Procedure checkcolor
  LoadRGB $mouse
  IF {RGBRed} = 167 and {RGBGreen} = 255 and {RGBBlue} = 255
    delay 1000
    LeftClick
    SetConst $result = false
  end
end

Procedure Work using x_coord1, y_coord1, x_coord2, y_coord2
  If $result = true
    MousePos $x_coord1, $y_coord1
    delay 500
    leftclick
    delay 500
    MousePos $x_coord2, $y_coord2
    delay 500
    call checkcolor
  End
End

// mainline
While $result = true
  delay 600000
  loop 2
    Call Work 279, 752, 762, 140
    Call Work 396, 749, 810, 171
    Call Work 496, 757, 862, 198
    Call Work 592, 761, 909, 224
    Call Work 682, 757, 960, 256
  end
end


I have a suspicion though, that this isn't the entirety of the code, in which case what I've put in the "mainline" segment here, probably needs to be proceduralized...

-Triane
DaMOB
I have no idea what he wanted in his code since it wasn't even beautified (Ipa, used to kick all asses over that) but I do know this the code you wrote is way way way above his competency level so he will have no idea how to handle it or what it is even doing. He will probably treat it like black voodoo magic and simply C&P it.
Triane
LoL -- given what I've seen, it's pretty hard to argue with your expectations smile.gif

-Triane
Bear
QUOTE(Triane @ Aug 8 2009, 10:10 AM) *
LoL -- given what I've seen, it's pretty hard to argue with your expectations smile.gif

-Triane


Looking at the New Complex code for the state of Arguing tongue.gif
Once the Results = False there's no statement to ever make it true again, the macro would End.
DaMOB
QUOTE(Bear @ Aug 8 2009, 02:51 PM) *
QUOTE(Triane @ Aug 8 2009, 10:10 AM) *
LoL -- given what I've seen, it's pretty hard to argue with your expectations smile.gif

-Triane


Looking at the New Complex code for the state of Arguing tongue.gif
Once the Results = False there's no statement to ever make it true again, the macro would End.

I think he wrote it, and judging by what he mentioned, based on more code that was not put up so it is unknown to us. Based on the rule of logic that code, that we never saw, should have somewhere in it a state checking and setting routine/routines but that is just a wild ass guess on my part.
Triane
QUOTE(Bear @ Aug 8 2009, 03:51 PM) *
Looking at the New Complex code for the state of Arguing tongue.gif
Once the Results = False there's no statement to ever make it true again, the macro would End.

From the original code cleaned up as per my stated expectations:

CODE
Procedure checkcolor
  LoadRGB $mouse
  IF {RGBRed} = 167 and {RGBGreen} = 255 and {RGBBlue} = 255
    delay 1000
    LeftClick
    Stop
  end
end

Once the "IF" test passed, the macro would execute the "Stop" instruction, thereby ending the macro, albeit messily (I generally hate "STOP" type logic). Using only the code [we] were given, my method accomplishes the same net result, but avoids using messy code-abortions like "Stop"...

-Triane
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.