Time ======= Time related methods ------------ TTimeFormat ~~~~~~~~~~~~ .. code-block:: pascal type TTimeFormat = (Time_Formal, Time_Short, Time_Abbrev, Time_Bare, Time_FStop, Time_Formal_Long); Formats used when converting time to string. ------------ srl.MsToTime ~~~~~~~~~~~~~ .. code-block:: pascal function TSRL.MsToTime(const MS: UInt64; const Format: TTimeFormat): String; constref; Converts milliseconds to a string following the given time-format. ------------ srl.TimeRunning ~~~~~~~~~~~~~~~~ .. code-block:: pascal function TSRL.TimeRunning(TheType: TTimeFormat = Time_Formal_Long): String; constref; Returns time the script has been running as a string with the given time-format. ------------ srl.WaitFunc ~~~~~~~~~~~~~ .. code-block:: pascal function TSRL.WaitFunc(Func: function: Boolean; WaitPerLoop, MaxTime: Integer): Boolean; constref; Waits till the given function returns ``True``, or otherwise time out defineds by ``MaxTime``. ------------ srl.WaitTypeFunc ~~~~~~~~~~~~~~~~~ .. code-block:: pascal function TSRL.WaitTypeFunc(Func: function: Boolean of object; WaitPerLoop, MaxTime: Integer): Boolean; constref; Waits till the given function returns ``True``, or otherwise time out defineds by ``MaxTime``. ------------ TTimeMarker ~~~~~~~~~~~ .. code-block:: pascal type TTimeMarker = record time, startTime: LongWord; paused: Boolean; end; Timer type which is useful for loops, timing and writing progress reports. .. note:: - by Bart de Boer ------------ TTimeMarker.Start ~~~~~~~~~~~~~~~~~ .. code-block pascal procedure TTimeMarker.Start(); Starts the timer. Can also be used when paused to continue where it left. .. note:: - by Bart de Boer Example: .. code-block:: pascal myTimer.Start(); ------------ TTimeMarker.Reset ~~~~~~~~~~~~~~~~~ .. code-block pascal procedure TTimeMarker.Reset(); Stops the timer and resets it to zero. .. note:: - by Bart de Boer Example: .. code-block:: pascal myTimer.Reset(); ------------ TTimeMarker.Pause ~~~~~~~~~~~~~~~~~ .. code-block pascal procedure TTimeMarker.Pause(); Pauses the timer. It can be continued with start(). .. note:: - by Bart de Boer Example: .. code-block:: pascal myTimer.Pause(); TakeABreak(90000); myTimer.Start(); ------------ TTimeMarker.GetTime ~~~~~~~~~~~~~~~~~~~ .. code-block pascal function TTimeMarker.GetTime(): UInt64; Gets the time from the timer. Returns zero if the timer was not set. .. note:: - by Bart de Boer Example: .. code-block:: pascal myTimer.start(); repeat DoStuff; until(myTimer.GetTime() > 60000); ------------ TTimeMarker.GetTotalTime ~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block pascal function TTimeMarker.GetTotalTime(): UInt64; Gets the time from the timer including the time it was paused. Returns zero if the timer was not set. .. note:: - by Bart de Boer Example: .. code-block:: pascal BreakTime := MyTimer.GetTotalTime() - MyTimer.GetTime(); ------------ TCountDown ~~~~~~~~~~~~~~~~~~~ A neat and simple timer type. Example: .. code-block:: pascal myTimer.Init(3000); //3000ms while not myTimer.IsFinished() do {do something}; myTimer.Restart(Random(-200,200)); //3000 +/- 200ms while not myTimer.IsFinished() do {do something}; ------------