Jump to content

Recommended Posts

Posted

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?

  • Administrators
Posted

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)


 

Posted

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.

Posted

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...

  • Administrators
Posted

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)


 

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
  • Recently Browsing   0 members

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