Time

Time related methods


TTimeFormat

type TTimeFormat = (Time_Formal, Time_Short, Time_Abbrev, Time_Bare, Time_FStop, Time_Formal_Long);

Formats used when converting time to string.


srl.MsToTime

function TSRL.MsToTime(const MS: UInt64; const Format: TTimeFormat): String; constref;

Converts milliseconds to a string following the given time-format.


srl.TimeRunning

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

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

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

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

Starts the timer. Can also be used when paused to continue where it left.

Note

  • by Bart de Boer

Example:

myTimer.Start();

TTimeMarker.Reset

Stops the timer and resets it to zero.

Note

  • by Bart de Boer

Example:

myTimer.Reset();

TTimeMarker.Pause

Pauses the timer. It can be continued with start().

Note

  • by Bart de Boer

Example:

myTimer.Pause();
TakeABreak(90000);
myTimer.Start();

TTimeMarker.GetTime

Gets the time from the timer. Returns zero if the timer was not set.

Note

  • by Bart de Boer

Example:

myTimer.start();
repeat
  DoStuff;
until(myTimer.GetTime() > 60000);

TTimeMarker.GetTotalTime

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:

BreakTime := MyTimer.GetTotalTime() - MyTimer.GetTime();

TCountDown

A neat and simple timer type.

Example:

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};