Jump to content
Sign in to follow this  

Running a Func() every 10 seconds

Recommended Posts


Hi there,

what I had expected to be pretty easy in theory didn't turn out the way I had wanted it to.

I have my script which just does all kinds of things, but every 10 seconds I need a certain function to be run.

I put a TimerInit() at the start (before the loop) and used TimerDiff in the loop, but this didn't work.

Here's an example:

$Timer = TimerInit()

While 1
    If IsInt(TimerDiff($Timer) / 10000) = 1 Then
            MsgBox(0,"","(Another) 10 seconds have passed")

What's a better way of doing this :(?

Checking if TimerDiff($Timer) > 10000 and then resetting the timer?


P.S: Perhaps it's because when checking the time it'll never be a integer, because it just skips that time doing other things, resulting in the time being 17.98876 the first time and 18.00256 the second time it polls, for example. If this is the case then putting more code in the loop will only make it more inaccurate I think, and my script obviously has a lot more in the loop than the example does.

Share this post

Link to post
Share on other sites

You are going to chew alot of cycles this way, how accurate does this need to be? Perhaps a Sleep(1000) in there would smooth things out by giving other things a chance to run.

Also, for the check, this may or may not run faster:

Mod(TimerDiff($Timer), 10000) < 500
Edited by Fulano

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post

Link to post
Share on other sites

AdlibEnable ( "test" 10000)

While 1

Func test()
    MsgBox(0, "", "test")

Edited by wwwvgtulzcomua


Share this post

Link to post
Share on other sites

AdlibRegister works like a charm, thanks :(.

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.