AntiFros Posted December 20, 2013 Share Posted December 20, 2013 For example: While 1 Sleep(100) check() Sleep(100) check() Sleep(100) check() Sleep(100) check() Sleep(100) exitloop Wend Func check() If "loop" then exitloop Else anotherfunc() Endif Endfunc Link to comment Share on other sites More sharing options...
BugFix Posted December 20, 2013 Share Posted December 20, 2013 What is the sense of this? If you check inside a loop, if it's a loop, the result is everytime true. Best Regards BugFix Link to comment Share on other sites More sharing options...
AlmarM Posted December 20, 2013 Share Posted December 20, 2013 While 1 Since it's a 1, it's always going to be inside a loop, unless you call ExitLoop. Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
jdelaney Posted December 20, 2013 Share Posted December 20, 2013 (edited) You won't be able to exitloop inside of a function (unless you specifically have a loop in your function). You can return a boolean from the function, which can conditionally exit the loop with an if then statement. Currently, your 'loop' is technically not a loop, since you ALWAYS exit after calling the function 4 times...you might as well just have the four function calls Example Global $i = 0 Global $iMax = 4 While True Sleep(100) If check() Then ExitLoop EndIf Wend ConsoleWrite("Loop is completed" & @CRLF) Func check() If $i = $iMax Then Return True Endif $i+=1 ConsoleWrite("Will continue the loop" & @CRLF) Return False Endfunc oh, your real question is how to see if you are calling your function from inside the loop, while inside the function...no, that can not be done, through a command, but can be done through logic, and default params, like such: While True check(True) ExitLoop Wend check() ConsoleWrite("Loop is completed" & @CRLF) Func check($bInsideLoop = False) If $bInsideLoop Then ConsoleWrite("Function called from INSIDE a loop" & @CRLF) Else ConsoleWrite("Function called from OUTSIDE a loop" & @CRLF) EndIf Endfunc Edited December 20, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. 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