Sign in to follow this  
Followers 0
litlmike

If Divisible by 5, then Func (). Or Every fifth time.

6 posts in this topic

How can I call this only when the counter is divisble by 5?

Example:

Lets say that I have this function, but I only want it to call Func Msg_Box every 5th time.

$i = 0
While $i < 100
    Func Msg_Box ()
    $i +=1
WEnd

Func Msg_Box ()
    MsgBox(4096, "Test", "This box will time out in 1 second", 1)
    Sleep (2000)
EndFunc

Share this post


Link to post
Share on other sites



Whats wrong with Mod? It works fine. You could always do the division yourself and check for a decimal.

Share this post


Link to post
Share on other sites

Actually, to play Devil's Advocate, is there a way to do this without using Mod()?

For $i = 0 To 99
 If IsInt($i / 5) Then Msg_Box ()
Next
 
Func Msg_Box ()
    MsgBox(4096, "Test: " & $i, "This box will time out in 1 second")
    Sleep(2000)
EndFunc

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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