Blue Eye Logo

Blue Eye Macro

Automation is freedom
It is currently Fri Dec 06, 2019 6:01 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Code: Convert milliseconds to hh:mm:ss
Thanked: 0 time(s)  Unread post Posted: Fri Nov 01, 2019 11:59 pm 
New User
New User



Joined: Tue Oct 01, 2019 5:44 pm
Posts: 6
Been thanked: 0 time(s)
Has thanked: 1 time(s)
Contribution Points: 116
Example code to convert milliseconds, as returned by a stopwatch, to zero-filled hh:mm:ss.
Code:
 begin
     // convert milliseconds to hh:mm:ss (whole seconds)
     Variable.Set("runtime", "20000000")
     Function.Execute("convert ms to hhmmss")
 end

function("convert ms to hhmmss")
     begin
          Variable.Copy("runtime", "ms")
          Variable.Divide (Math)("ms", "1000")
          Variable.Floor (Math)("ms")
          Variable.Copy("ms", "s")
          Variable.To modulo (Math)("s", "60")
          Variable.Copy("ms", "m")
          Variable.Divide (Math)("m", "60")
          Variable.Floor (Math)("m")
          Variable.Copy("m", "h")
          Variable.To modulo (Math)("m", "60")
          Variable.Divide (Math)("h", "60")
          Variable.Floor (Math)("h")
          Function.Execute setting 3 variables("ZeroFillTime","strHour", "{h}", "strMinutes", "{m}", "strSeconds", "{s}")
          Window.Display message box("{strFormattedTime}", "yes")
     end
function

function("ZeroFillTime")
     begin
          if  Variable.Is less than (Math)("strHour", "10")
               begin
                    Variable.Evaluate (Text)("0{strHour}", "strHour")
               end
          if  Variable.Is less than (Math)("strMinutes", "10")
               begin
                    Variable.Evaluate (Text)("0{strMinutes}", "strMinutes")
               end
          if  Variable.Is less than (Math)("strSeconds", "10")
               begin
                    Variable.Evaluate (Text)("0{strSeconds}", "strSeconds")
               end
          Variable.Evaluate (Text)("{strHour}:{strMinutes}:{strSeconds}", "strFormattedTime")
     end
function


Top
 Profile  
Reply with quote  
 Post subject: Re: Code: Convert milliseconds to hh:mm:ss
Thanked: 1 time(s)  Unread post Posted: Sat Nov 02, 2019 5:55 am 
Partner / License admin
Partner / License admin
User avatar



Joined: Sun Oct 10, 2010 5:16 pm
Posts: 1967
Location: USA
Been thanked: 437 time(s)
Has thanked: 34 time(s)
Contribution Points: 16794
very cool!

_________________
----------------------------------------Syrifina---------------------------------------------------
PM me for licenses and/or licensing information: Click Here
[Be sure to include and update your profile with your BE ID]

Forum Rules
Reminder of rules regarding Contribution points
Getting started in 1, 2, 3
Virtual Drivers; Manual Installers


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group