joeyg37 Posted March 20, 2009 Share Posted March 20, 2009 well im new and i dont know much about this i think it got it mostly rite but i get an error and need to fix it i cant figure it out What im trying to do it loop those 2 things untill MY ERROR : ==> "While" statement has no matching "Wend" statement.: func CheckRestart() expandcollapse popupHotKeySet("{F5}" ,"start") HotKeySet("{F6}" ,"stop") HotKeySet("{F7}" ,"_exit") Global $on = False func start() $on = True EndFunc func stop() $on = False EndFunc func _exit() Exit EndFunc while 1=1 sleep(30) While $on = True CheckRestart() WEnd func CheckRestart() while 1=1 $coord = PixelSearch( 326, 665, 364, 704, 0x00FF00 ) If Not @error Then MouseClick("left", 344, 679, 2) Sleep(500) MouseClick("left", 126, 680, 2) func progress() endif wend EndFunc func progress() while 1=1 $coord = PixelSearch( 174, 547, 174, 547, 0x25DF32 ) If Not @error Then Send(4) Sleep(1500) Send(5) sleep(1500) Send(6) sleep(1500) Else Send(1) Sleep(1500) Send(2) sleep(1500) Send(3) sleep(1500) CheckRestart() EndIf WEnd EndFunc Link to comment Share on other sites More sharing options...
Skruge Posted March 20, 2009 Share Posted March 20, 2009 (edited) The Wend here matches the second While. You need to add another one after it to match the first one.while 1=1 sleep(30) While $on = True CheckRestart() WEndYou can't declare a function within another function. It looks like you're trying to call the progress() function, so change "func progress()" to "progress()" <span class="postcolor">func CheckRestart() while 1=1 $coord = PixelSearch( 326, 665, 364, 704, 0x00FF00 ) If Not @error Then MouseClick("left", 344, 679, 2) Sleep(500) MouseClick("left", 126, 680, 2) func progress() endif wend EndFunc</span> Make those two changes and you'll be able to compile, but there are other flaws you need to consider. The While loop in the progress() function will never end since there's no ExitLoop or Return. CheckRestart() and progress() both call each other, so you may run into recursion errors as the functions call each other continuously. Based on these observations, it sounds like the best option is to change the CheckRestart() call within progress() to either ExitLoop or Return. Edited March 20, 2009 by Skruge [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
joeyg37 Posted March 20, 2009 Author Share Posted March 20, 2009 The Wend here matches the second While. You need to add another one after it to match the first one.You can't declare a function within another function. It looks like you're trying to call the progress() function, so change "func progress()" to "progress()"Make those two changes and you'll be able to compile, but there are other flaws you need to consider.The While loop in the progress() function will never end since there's no ExitLoop or Return.CheckRestart() and progress() both call each other, so you may run into recursion errors as the functions call each other continuously.Based on these observations, it sounds like the best option is to change the CheckRestart() call within progress() to either ExitLoop or Return.im not sure how to add the call, return or exitloop. im really new to autoit i dont know much at all lol Link to comment Share on other sites More sharing options...
jvanegmond Posted March 20, 2009 Share Posted March 20, 2009 im not sure how to add the call, return or exitloop. im really new to autoit i dont know much at all lolRead the help file and take a programming 101 class. github.com/jvanegmond Link to comment Share on other sites More sharing options...
BinaryBrother Posted March 20, 2009 Share Posted March 20, 2009 (edited) expandcollapse popupGlobal $on = False Func start() $on = True EndFunc Func stop() $on = False EndFunc While 1 = 1 Sleep(30) While $on = True $coord = PixelSearch(326, 665, 364, 704, 0x00FF00) If Not @error Then MouseClick("left", 344, 679, 2) Sleep(500) MouseClick("left", 126, 680, 2) progress() EndIf WEnd WEnd Func progress() While 1 = 1 $coord = PixelSearch(174, 547, 174, 547, 0x25DF32) If Not @error Then Send(4) Sleep(1500) Send(5) Sleep(1500) Send(6) Sleep(1500) Else Send(1) Sleep(1500) Send(2) Sleep(1500) Send(3) Sleep(1500) ExitLoop EndIf WEnd EndFunc Func OnAutoItExit() Exit EndFunc I didn't check the syntax... but it looks right... What you had is Grade A terrible... No offense! Your new... When I first started, I was calling Functions from within functions in loops as well, as a matter of fact I recently posted an example script like that, I knew it was terrible, but it was a quick fix for a problem, and I was giving up the project... but it is by ANY-MEANS a terrible bad idea... Edited March 20, 2009 by BinaryBrother SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
BinaryBrother Posted March 20, 2009 Share Posted March 20, 2009 Oh, add this to the top of your script... HotKeySet("{F5}" ,"start") HotKeySet("{F6}" ,"stop") HotKeySet("{F7}" ,"_exit") I'm seem to have forgotten it... SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now