Sign in to follow this  
Followers 0
Sunblood

Timer help! How do I stop a timer?

5 posts in this topic

I have a script that uses the following code:

$timer = TimerStart()
While 1
   $dif = TimerStop()
   If $dif > 60000 Then
      Exitloop
   EndIf
Wend

(There is more to it that allows it to loop back again)

The problem is, sometimes it will loop back around and the timer will still be going, and it will be longer than 60 seconds, thus instantly exiting the loop.

How can start the timer over?


Share this post


Link to post
Share on other sites



I have a script that uses the following code:

$timer = TimerStart()
While 1
   $dif = TimerStop()
   If $dif > 60000 Then
      Exitloop
   EndIf
Wend

(There is more to it that allows it to loop back again)

The problem is, sometimes it will loop back around and the timer will still be going, and it will be longer than 60 seconds, thus instantly exiting the loop.

How can start the timer over?

Check the timerstop docs, you need to pass it $timer.

$dif = TimerStop($timer)

Share this post


Link to post
Share on other sites

Check the timerstop docs, you need to pass it $timer.

$dif = TimerStop($timer)
Err, that was just a typo in the code I posted. I have that :ph34r:

The timer still doesn't actually stop. It just finds the time since it started.


Share this post


Link to post
Share on other sites

That's because TimerStop() is incorrectly named... TimerStop(). It's new name (Which will be changed in the latest stable release) is TimerDiff() which is what it does (It is already changed in the unstable build).

Why do you need to stop the timer? Do you need to reset it, perhaps? It's not actually a timer running using resources or anything, if that was what you were thinking...

Share this post


Link to post
Share on other sites

Err, that was just a typo in the code I posted.  I have that :ph34r:

The timer still doesn't actually stop.  It just finds the time since it started.

Oh ok, just reinit $timer then with TimerStart($timer)

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