Jump to content

Calculating time difference?


huldu
 Share

Recommended Posts

Ive tried various ways to try calculate the time difference between two different values, my math knowledge is pretty low i know :)

The thing i started with first was using @Min and @Sec, but this was way too complicated for me... Then i switched over to TimerInit() which is alot easier to understand. However i still have a few issues.

What am i looking for? The program that im working on (atm im just trying to get this timer working), is to do a timestamp when the program start then during the program it will inform the user how long it has been running. I just couldnt get the math right using @Min and @sec, i tried.. oh i tried. Seems its quite hard to be honest. But then i found Timerinit() which seems to do the same thing, but in a better way!

Now the problem im having with Timerinit() is that it shows far too many decimalplaces(?), like 2.02912281. I just wonder how do i get rid of the decimalplaces(!) to just show the miliseconds? Ill probably need to do something on the value itself later to show it in seconds... This is what ive done sofar:

$begin = TimerInit()
$test = 0
While 1
    
    $dif = TimerDiff($begin)
    
    $test = Round($dif, -1)
    
    $Second = $test / 1000
    
    $change = Round($second, 1)
    
    ToolTip("Dif: " & $dif & " Dif: " & $test & " Runtime: " & $second ,0,0)
    
    Sleep(50)   
WEnd

Its really messy and to be honest, i dont think using Round() is the best way. I was looking through some ideas tho, one would be to convert it to a string and manipulate it? But it looks seriously complicated aswell :)

Help me to show a single value on a decimal number, please! ie turn 5.23121 into.. a 5 (for example)

"I'm paper, rock is fine, nerf scissors!!!"

Link to comment
Share on other sites

I think... i got it!

Using Int() seems to remove the decimals! wonderful!

$begin = TimerInit()

While 1
    $dif = TimerDiff($begin)
    
    $test = Int($dif)
    
    $change = $test / 1000
    
    $convert = Int($change)
    
    ToolTip("Test: " & $convert & " seconds",0,0)
    sleep(50)
WEnd
Edited by huldu

"I'm paper, rock is fine, nerf scissors!!!"

Link to comment
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
 Share

  • Recently Browsing   0 members

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