uchinka

Help me ! for loop cover number to time

5 posts in this topic

#1 ·  Posted (edited)

Func Sec2Time($nr_sec)
   $sec2time_hour = Int($nr_sec / 3600)
   $sec2time_min = Int(($nr_sec - $sec2time_hour * 3600) / 60)
   $sec2time_sec = $nr_sec - $sec2time_hour * 3600 - $sec2time_min * 60
   $sec2time_milli = $nr_sec - $sec2time_hour * 3600 - $sec2time_min * 60 
   Return StringFormat('%02d:%02d:%02d.%02d', $sec2time_hour, $sec2time_min, $sec2time_sec,$sec2time_milli)
EndFunc
For $i = 0 to 999999999
ToolTip(Sec2Time($i),0,0)
Sleep(100); change
Next

how to cover number in for loop to time type: "00:00:00.00" => HOUR:MIN:MSEC.MILLISECOND

1Msec = 100 millisecond

Edited by uchinka

Share this post


Link to post
Share on other sites



Something like this?

Global $sDisplayTime = ""
Global $iTimer = TimerInit()
AdlibRegister("Sec2Time", 100)
While 1
    Sleep(50)
    ToolTip($sDisplayTime, 0, 0)
WEnd
Func Sec2Time()
    Local $iCounter = TimerDiff($iTimer) ; Milliseconds since start of script
    Local $iTempSec = $iCounter / 1000 ; Seconds since start of script
    $iHour = Int($iTempSec / 3600)
    $iMin = Int(($iTempSec - $iHour * 3600) / 60)
    $iSec = Int($iTempSec - $iHour * 3600 - $iMin * 60)
    $iMilli = Mod($iCounter, 1000)
    $sDisplayTime = StringFormat('%02d:%02d:%02d.%03d', $iHour, $iMin, $iSec, $iMilli)
EndFunc   ;==>Sec2Time

 

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

OK good. Thanks u bro !

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

9 hours ago, water said:

Something like this?

Global $sDisplayTime = ""
Global $iTimer = TimerInit()
AdlibRegister("Sec2Time", 100)
While 1
    Sleep(50)
    ToolTip($sDisplayTime, 0, 0)
WEnd
Func Sec2Time()
    Local $iCounter = TimerDiff($iTimer) ; Milliseconds since start of script
    Local $iTempSec = $iCounter / 1000 ; Seconds since start of script
    $iHour = Int($iTempSec / 3600)
    $iMin = Int(($iTempSec - $iHour * 3600) / 60)
    $iSec = Int($iTempSec - $iHour * 3600 - $iMin * 60)
    $iMilli = Mod($iCounter, 1000)
    $sDisplayTime = StringFormat('%02d:%02d:%02d.%03d', $iHour, $iMin, $iSec, $iMilli)
EndFunc   ;==>Sec2Time

 

$iMilli run 1 to 100 

Edited by uchinka

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Maybe if you modify this line:

$sDisplayTime = StringFormat('%02d:%02d:%02d.%01d', $iHour, $iMin, $iSec, $iMilli/100)

 

Edited by czardas
1 person likes this

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