Sign in to follow this  
Followers 0
AntiFros

How to detect if its loop or not.

4 posts in this topic




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  

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0