Jump to content

How to detect if its loop or not.


AntiFros
 Share

Recommended Posts

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.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...