OminousIdol Posted December 23, 2005 Share Posted December 23, 2005 I am running Functions for a long period of time... After awhile I will get a Overstack Flow Error because of Sleep... How could I fix this? expandcollapse popupWinActivate ("Mythia - Mozilla Firefox", "") Sleep(2000) Call ("FindAttack") Func FindAttack() Send("^f") Sleep(500) Send("Attack") Sleep(500) Call("Color") EndFunc Func FindWait() Send("^f") Sleep(500) Send("Wait here a while.") Sleep(500) $Wait = PixelSearch(527, 257, 803, 562, 0x38D878) If @error Then Call("Tab7") Else MouseClick("left", $Wait[0], $Wait[1]) Sleep(20000) Call ("Tab7") EndIf EndFunc Func Color() $coord = PixelSearch(530, 484, 740, 557, 0x38D878) If @error Then Call ("FindWait") Else MouseClick("left", $coord[0], $coord[1]) Sleep(20000) Call ("Tab7") EndIf EndFunc Func Tab7() $Back = PixelSearch(344, 204, 733, 503, 0xD4D0C8) If @error Then Call ("FindAttack") Else MouseClick("left", $Back[0], $Back[1]) Sleep(20000) Call("FindAttack") EndIf EndFunc Thanks Link to comment Share on other sites More sharing options...
themax90 Posted December 23, 2005 Share Posted December 23, 2005 Everytime you call a function, inside of another function, that goes to the next one without stopping, it overstacks the program. This will do the same thing. StartFlow() Func StartFlow() KeepFlow() EndFunc Func KeepFlow() StartFlow() EndFunc It's a never ending function that overstacks and terminates. Just try to be a bit more clean with the code, and not link to each other. Link to comment Share on other sites More sharing options...
OminousIdol Posted December 23, 2005 Author Share Posted December 23, 2005 (edited) Ok... so how would I clean the code up then? Edited December 23, 2005 by OminousIdol Link to comment Share on other sites More sharing options...
themax90 Posted December 23, 2005 Share Posted December 23, 2005 That is something you need to figure out, if I go out giving you the answers you will never learn. Run this through Tidy, and make sure there is no possible explanation for an infinite loop. That's all I can say. AutoIt Smith Link to comment Share on other sites More sharing options...
OminousIdol Posted December 23, 2005 Author Share Posted December 23, 2005 But the thing is that I need it to loop forever... hmm would it be smart to to call a differnt au3 scripts? Then it would be opening and closing the functions so it wont cause a overflow? Thanks Link to comment Share on other sites More sharing options...
therks Posted December 23, 2005 Share Posted December 23, 2005 (edited) Don't use CALL()!!! Also, look into using While..WEnd and Do..Until for infinite loops. Edited December 23, 2005 by Saunders My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
LxP Posted December 23, 2005 Share Posted December 23, 2005 (edited) What you are doing does not require any function calls. You appear to want something close to this:expandcollapse popupWinActivate('Mythia - Mozilla Firefox') Sleep(2000) While 1 ; Find attack Send('^f') Sleep(500) Send('Attack') Sleep(500) ; Colour $Coord = PixelSearch(530, 484, 740, 557, 0x38D878) If Not @Error Then MouseClick('', $Coord[0], $Coord[1]) Sleep(20000) Else ; Find wait Send('^f') Sleep(500) Send('Wait here a while.') Sleep(500) $Wait = PixelSearch(527, 257, 803, 562, 0x38D878) If Not @Error Then MouseClick('', $Wait[0], $Wait[1]) Sleep(20000) EndIf EndIf ; Tab 7 $Back = PixelSearch(344, 204, 733, 503, 0xD4D0C8) If Not @Error Then MouseClick('', $Back[0], $Back[1]) Sleep(20000) EndIf WEndWhile 1..WEnd gives you an infinite loop. As you are not continually entering functions without exiting them again, you will receive no stack overflow errors. Edited December 23, 2005 by LxP Link to comment Share on other sites More sharing options...
therks Posted December 25, 2005 Share Posted December 25, 2005 You're too nice Alex. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
MrSpacely Posted December 25, 2005 Share Posted December 25, 2005 Nice Fix And remember there is almost no need to Call() Call would actually be nessesary when testing script when you type the function. All other ways should not involve using call 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