forgetoo Posted May 3, 2009 Share Posted May 3, 2009 Error: Recursion level has been exceeded - Autoit will quit to prevent stack overflow. Thats the error. I actually want my things to loop over and over. I had it going without any sleeps and that happened. Right now I've tested it but it's not error'd out yet. I assume it will at some point, but because of the sleeps it's going to take it alot longer. Is there anyway to fix this issue while running the same checks over and over. Here is my code. expandcollapse popupFunc CntrlQ() ToolTip('Warping to Station"',0,0) Sleep ( 500 ) EndFunc Global $Shield = 0 Func ShieldCheck(); Checks Shields to see if their in Danger Level ToolTip('Checking Shields"',0,20) PixelSearch ( 446, 685, 446, 685, 0xBCBCBC, 10 ) If @error Then ToolTip('Shields cntrlq"',0,0) Sleep ( 250 ) Call ( "CntrlQ" ) EndIf Sleep ( 500 ) Call ( "LocalCheck" ) EndFunc ; +37 pixel to each spot ; Spot1 278, 239 ; Spot2 278, 276 ; Spot3 278, 313 ; Spot4 278, 350 ; Spot5 278, 387 ; Spot6 278, 424 ; Spot7 278, 461 ; Spot8 278, 498 ; Spot9 278, 535 ; Spot10 278, 572 ; Spot11 278, 609 ; Spot12 278, 646 ; Spot13 278, 683 ; Spot14 278, 720 ; Neut Color #878989 ; At War Color #980A0A ; Bad Standins #C14603 Global $LocalCheck = 0 Global $HostileColor[3][1] = [[0x878989],[0x980A0A],[0xC14603]] Global $HSpot[14][2] = [[278, 239],[278, 276],[278, 313],[278, 350],[278, 387],[278, 424],[278, 461],[278, 498], _ [278, 535],[278, 572],[278, 609],[278, 646],[278, 683],[278, 720]] Func LocalCheck(); Check Local for Hostiles ToolTip('Checking Local"',0,30) For $y = 0 to 2 For $x = 0 to 13 $coord = PixelSearch($HSpot[$x][0], $HSpot[$x][1], $HSpot[$x][0], $HSpot[$x][1], $HostileColor[$y][0], 20 ) If Not @error Then ToolTip('Hostile cntrlq"',0,0) Sleep ( 250 ) Call ( "CntrlQ" ) EndIf Next Next Sleep ( 500 ) Call ( "ShieldCheck" ) EndFunc ; Local calls ShieldCheck and ShieldCheck calls Local to Loop checks Call ( "LocalCheck" ) Basically Local calls shield, shield calls local. So is there a way to not get this recursion error? Or will I not get it because of the sleep commands I've added in so it's slower now? Link to comment Share on other sites More sharing options...
Khab Posted May 3, 2009 Share Posted May 3, 2009 I'm not that familiar with how AutoIt handles recursion, but if you're recursively calling scripts from within each other with no limits you'll run into resource issues at some point regardless of a built in recursion limit in AutoIt. I'd hazard a guess that when a function calls another function it doesn't end the first function instance, so you're going to end up with umpteen million instances of each function trying to process. I think preferably you want it to: Call LocalCheck End LocalCheck Call ShieldCheck End ShieldCheck and loop that Whereas if I'm reading it right at the moment you're doing: Call LocalCheck Call ShieldCheck Call LocalCheck Call ShieldCheck etc without ever terminating any of the function instances. Link to comment Share on other sites More sharing options...
forgetoo Posted May 3, 2009 Author Share Posted May 3, 2009 Ok that makes good sense. But how can I Loop them in that case. Link to comment Share on other sites More sharing options...
Yashied Posted May 3, 2009 Share Posted May 3, 2009 What are the reasons you are using the Call()?Why do not you do the following?While 1 LocalCheck() ShieldCheck() WEnd My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Khab Posted May 3, 2009 Share Posted May 3, 2009 Good suggestion Yashied, that way it will run a function, end the function, run the next, end the next,re-run the first etc. Much cleaner way to do it. Link to comment Share on other sites More sharing options...
forgetoo Posted May 3, 2009 Author Share Posted May 3, 2009 I actually figured out a way to do it very easily with a Do Until. Is there any reason I would want to use a While WEnd over a Do Until? Global $Loop = 0 Func LocalLoop() Do Call ( "LocalCheck" ) Call ( "ShieldCheck" ) Until $Loop = 1 EndFunc Link to comment Share on other sites More sharing options...
Yashied Posted May 3, 2009 Share Posted May 3, 2009 (edited) I actually figured out a way to do it very easily with a Do Until. Is there any reason I would want to use a While WEnd over a Do Until? Global $Loop = 0 Func LocalLoop() Do Call ( "LocalCheck" ) Call ( "ShieldCheck" ) Until $Loop = 1 EndFuncforgetoo, DO NOT use the Call() function, where it is not required. Edited May 3, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Khab Posted May 3, 2009 Share Posted May 3, 2009 (edited) As far as I'm aware the only real difference between a While and a Do loop is the While loop tests the condition BEFORE each loop starts, whereas Do tests the condition AFTER. For your case, I can't see that mattering as the condition is never in an end state anyway. But, why still using Call()? Edited May 3, 2009 by Khab Link to comment Share on other sites More sharing options...
KaFu Posted May 3, 2009 Share Posted May 3, 2009 As far as I'm aware the only real difference between a While and a Do loop is the While loop tests the condition BEFORE each loop starts, whereas Do tests the condition AFTER.You're right, this is a much easier way to call the functions in a loop while 1 LocalCheck() ShieldCheck() wend OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
UEZ Posted May 3, 2009 Share Posted May 3, 2009 Recursion is something like that: MsgBox(0, "Recursion", Fibonacci_r(10)) Func Fibonacci_r($f) If $f = 0 Then Return 0 If $f = 1 Then Return 1 Return Fibonacci_r($f - 1) + Fibonacci_r($f - 2) EndFunc Recursion is slower than the iterative method! UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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