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
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 [/code]
|