Sign in to follow this  
Followers 0
arminius

trying to copy and past a timed value

7 posts in this topic

ok what I'm trying to do is use a timer to record the time it takes to run a script, and displays the time it took at the end of the script

here is a simple version of what I'm trying to achieve.

CODE
$begin = TimerInit()

$dif = TimerDiff($begin)

ProgressOn("Progress Meter", "Increments every second", "0 percent")

For $i = 10 to 100 step 10

sleep(1000)

ProgressSet( $i, $i & " percent")

Next

ProgressSet(100 , "Done", "took $dif hours/mins")

sleep(5000)

ProgressOff()

so $dif is the timer value I belive? I wrote $dif at progress set 100 near the bottom, but as u can guess it just said $dif instead of the around 12 seconds it took.

so anyone got any advice?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

ok what I'm trying to do is use a timer to record the time it takes to run a script, and displays the time it took at the end of the script

here is a simple version of what I'm trying to achieve.

CODE
$begin = TimerInit()

$dif = TimerDiff($begin)

ProgressOn("Progress Meter", "Increments every second", "0 percent")

For $i = 10 to 100 step 10

sleep(1000)

ProgressSet( $i, $i & " percent")

Next

ProgressSet(100 , "Done", "took $dif hours/mins")

sleep(5000)

ProgressOff()

so $dif is the timer value I belive? I wrote $dif at progress set 100 near the bottom, but as u can guess it just said $dif instead of the around 12 seconds it took.

so anyone got any advice?

You need to have the $dif at the bottom.

$begin = TimerInit()


ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
$dif = TimerDiff($begin)
ProgressSet(100 , "Done", "took "& $dif &" hours/mins")
sleep(5000)
ProgressOff()
Edited by R6V2

Share this post


Link to post
Share on other sites

You need to have the $dif at the bottom.

$begin = TimerInit()


ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
$dif = TimerDiff($begin)
ProgressSet(100 , "Done", "took "& $dif &" hours/mins")
sleep(5000)
ProgressOff()
that's great guy thanks, but while I still got ya, it's bringing out a huge amount of digits I don't need, any advice on how to cut it down to just the few seconds it's ment to represent?

Share this post


Link to post
Share on other sites

Yeah, It's because TimerDiff, brings out every digit it can... :) Use this to cut it down.

$begin = TimerInit()


ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
$dif = TimerDiff($begin)
$Time = StringFormat("%.2f", $dif)
ProgressSet(100 , "Done", "took "& $time &" hours/mins")
sleep(5000)
ProgressOff()

How bout that? It will shorten it so it only displays like: 1.20 seconds.

Share this post


Link to post
Share on other sites

Yeah, It's because TimerDiff, brings out every digit it can... :) Use this to cut it down.

$begin = TimerInit()


ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
$dif = TimerDiff($begin)
$Time = StringFormat("%.2f", $dif)
ProgressSet(100 , "Done", "took "& $time &" hours/mins")
sleep(5000)
ProgressOff()

How bout that? It will shorten it so it only displays like: 1.20 seconds.

thanks that helped alot, but it's still displaying it in microseconds, do u know how to tell it to divide by a 1000, I'm not familer with this coding your using, if I need to bone up on it any idea where I can go to read?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

thanks that helped alot, but it's still displaying it in microseconds, do u know how to tell it to divide by a 1000, I'm not familer with this coding your using, if I need to bone up on it any idea where I can go to read?

:) im not familer with StringFormat either, but you can do:

$begin = TimerInit()


ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
$dif = TimerDiff($begin)
$Time = StringFormat("%.2f", $dif)
$Time=$Time/1000
$Actual = Round($Time, 0)
ProgressSet(100 , "Done", "took "& $Actual &" hours/mins")
sleep(5000)
ProgressOff()

If you really wanted to get accurate, you could read-up on the function StringFormat() which is huge, and I don't understand it, but good luck! :)

Edited by R6V2

Share this post


Link to post
Share on other sites

:) im not familer with StringFormat either, but you can do:

$begin = TimerInit()


ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
$dif = TimerDiff($begin)
$Time = StringFormat("%.2f", $dif)
$Time=$Time/1000
$Actual = Round($Time, 0)
ProgressSet(100 , "Done", "took "& $Actual &" hours/mins")
sleep(5000)
ProgressOff()

If you really wanted to get accurate, you could read-up on the function StringFormat() which is huge, and I don't understand it, but good luck! :)

perfect, thanks mate your tops, I nearly had another question when I went to test it by changing the sleep from 1000 to 2000 to see if the timer would change it's value, and was confused when the total time doubled, until I realised it was adding an extra second to every 10 cycles, I'm such a newb, but yeah I added sleeps elsewhere and it worked perfectly, so kudos

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