Progress Report¶
Formatted progress reports with bordered table output.
Credits: TaZe
TProgressReport¶
Progress report record for managing formatted table output with timing and print frequency control.
TProgressReport.Setup¶
procedure TProgressReport.Setup(title: String = 'ProgressReport'; headers: TStringArray = []; valueProvider: function: TStringArray of Object = nil; printInterval: Integer = ONE_MINUTE * 5);
Sets up the progress report with title and column headers.
Check the example in TProgressReport.Print for more information.
TProgressReport.Generate¶
function TProgressReport.Generate(values: TStringArray): String;
Generates a formatted report with the provided values in a bordered table format.
TProgressReport.Print¶
procedure TProgressReport.Print();
Displays the current report using the TProgressReport.ValueProvider function
to retrieve current values.
Keep in mind that calling this won’t do anything until
TProgressReport.PrintTimer.IsFinished is true.
Here is a short example of how to setup and print reports:
{$I WaspLib/osrs.simba}
function GetReportValues(): TStringArray;
begin
Result := [
GetTimeStamp(TIME_SHORT),
Logger.TimeRunning.ElapsedFmt(TIME_SHORT),
Antiban.TimeRunning.ElapsedFmt(TIME_SHORT),
ToStr(50)
];
end;
begin
Logger.Setup('Script Name');
ProgressReport.Setup(
'Script Name',
['Full script runtime:', 'Botting runtime:', 'Time spent in antiban:', 'Boss kills:'],
@GetReportValues,
ONE_SECOND
);
while True do
ProgressReport.Print();
end.
And the output should look something like this:
Succesfully compiled in 906.08 milliseconds.
+ Script Name ----------------------+
| Full script runtime: 00:00:06 |
| Botting runtime: 00:00:01 |
| Time spent in antiban: 00:00:00 |
| Boss kills: 50 |
+-----------------------------------+
Succesfully executed in 7976.01 milliseconds.