Page 1 of 1

TFeedbackProc

Posted: Fri Nov 20, 2020 2:06 pm
by dwilbourn
I would like to make use of the Feedback value in CountLinesInTextFile but I don't know how. The help just says "The type declaration TFeedbackProc defines a universal callback routine which is used in various mathematical procedures to provide feedback during time consuming calculations."
Is there an example of how to actually do this in code?

Re: TFeedbackProc

Posted: Mon Nov 23, 2020 5:23 pm
by hlohning
Here's a code snippet which creates the feedback. Please note the far declaration of the feedback procedure:

Code: Select all


(******************************************************************************)
procedure DoFeedback (Sender: TObject; StateCnt: double; PercentDone: double); far;
(******************************************************************************)

begin
FrmMain.ProgBar1.Value := (round(StateCnt/100000) mod 100);
Application.ProcessMessages;
end;



(******************************************************************************)
procedure TFrmMain.Button1Click(Sender: TObject);
(******************************************************************************)

var
  IFile : TextFile;
  nlin  : integer;

begin
if ODiag.Execute then
  begin
  AssignFile (IFile, ODiag.FileName);
  reset (IFile);
  nlin := CountLinesInTextFile (IFile, DoFeedback);
  closefile (IFile);
  end;
end;
Hope this helps, Hans

Re: TFeedbackProc

Posted: Fri Nov 27, 2020 12:53 am
by dwilbourn
Thanks, I will give that a go!