• support@ifer.cz
  • +420 2 4195 0607

Working with Log window

By Martin Cerny / Nov 24, 2016

Log window is available for informing user about progress of execution of data processing task.

Following methods are available for Log dialog:

procedure OpenLog(const Caption : string);
procedure MakeLogWindowStayOnTop;

procedure CloseLog;
procedure CloseLogWithDelay(const Delay_ms :integer);

procedure HideLog;
procedure ShowLog;
function  IsLogOpen : Boolean;

procedure Log(const str : string);
procedure LogExt(const str : string; appendNewLine : boolean);

OpenLog creates and shows on screen the Log dialog with window Caption.

MakeLogWindowStayOnTop will guarantee that the Log window will stay infront of other applications on the screen.

CloseLog will close and reset the Log window. CloseLogWithDelay will do the same but with time delay specified in miliseconds.

HideLog and ShowLog enables to hide and show again the Log window without changing content. IsLogOpen returns the information on current status of Log window.

Log and LogExt add new text to the Log window.

Log window may be completed with ProgressBar showing progress of the task execution. Several methods are available for handling ProgressBar:

procedure PrepareProgressBar(const NumberOfCycles_ :integer);
procedure StartProgressBarCycle(const MaxValue_ :integer);
procedure StepProgressBar;
procedure ResetProgressBar;
procedure PerformOneStepCycle;

Progress can be in two levels number of cycles and number of steps in each cycle. Such arrangement is handy in those cases when number of steps within each cycle is not known in advance.

StepProgressBar moves ProgressBar one step forward.

ResetProgressBar resets the status of ProgressBar to zero.

PerformOneStepCycle moves ProgressBar forwards for one cycle. This is useful for instance in those cases when there are no data within a cycle.

Example script demonstrates all main features of Log window:

var tbPlots :TTableWrapper;
    s :double;
    PlotID_ :integer;
begin
  HourGlassCursor;

  OpenLog('Summarize Basal Area');
  MakeLogWindowStayOnTop;

  PlotID_ := Plots[‘ID’]; //save current plot ID
  Trees.DisableControls; //avoid scrolling on the screen
  tbPlots := Project.GetQueryResult('SELECT ID FROM Plots');
  try
    PrepareProgressBar(tbPlots.RecordCount); //number of cycles
    tbPlots.First;
    while not tbPlots.EOF do begin
      Project.OpenPlot(tbPlots[‘ID’]);
      Log(format('Plot: %d (%s)',
                 [Plots.ValueAsInteger[‘ID’],Plots.ValueAsString[‘Name’]]));
      s:=0;
      if Trees.RecordCount=0 then
        PerformOneStepCycle
      else begin
        StartProgressBarCycle(Trees.RecordCount);  //number of steps in cycle
        Trees.First;
        while not Trees.EOF do begin
          StepProgressBar;
          s := s + Pi * power(Trees[‘DBH_mm’]/2000,2);
          Trees.Next;
        end;
      end; 
      Log(format(#9'Basal area = %0.2f m2',[s]));
      tbPlots.Next;
    end;

    ResetProgressBar;
    Log('');
    Log('Data processing finished.');
    CloseLogWithDelay(7000); //close in 7 seconds}

  finally
    tbPlots.Free;
    if PlotID_<>Plots[‘ID’] then
      Project.OpenPlot(PlotID_); //go back to starting plot
  end;
end.

Example script creates following Log window:


You must be logged in to post a comment