Jump to content
Sign in to follow this  
Thundorin

Execute "this" after X loops of a function

Recommended Posts

Hey im looking for a way to execute function2 after function1 has been cycled more then x times.

also function2 must reset the counter of function1 cycles.

I couldn't think of a code that exactly executes this, does anyone have an idea?

Share this post


Link to post
Share on other sites

Hi @Thundorin, and welcome to the AutoIt forums :welcome:
Use Global variables and For...Next loop:

HotKeySet("{ESC}", "ExitApplication")


Global $intCounter = 1


While 1
    Function1()
    If $intCounter > 10 Then Function2()
    Sleep(100)
WEnd

Func ExitApplication()
    Exit
EndFunc

Func Function1()
    ConsoleWrite("Function1 has been ran " & $intCounter & " times." & @CRLF)
    $intCounter += 1
EndFunc

Func Function2()
    ConsoleWrite("Function2!" & @CRLF)
    $intCounter = 1
    ConsoleWrite("Counter is now " & $intCounter & @CRLF)
    Exit
EndFunc

:)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...