The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



MathFeedBackProc


Unit:SDL_sdlbase
Class: none
Declaration: MathFeedBackProc: FeedBackProcType;

Some math calculations can consume a lot of computer time during which the application may show no reaction. In order to avoid this unfavorable situation, all the potentially time-consuming routines (i.e. SortArray, CalcCovar, CalcEigVec, CalcPrincComp, FindCenters, Invert, Square, SimPLS, MeanOfLayersToMatrix, StdDevOfLayersToMatrix, MinimumOfLayersToMatrix, MaximumOfLayersToMatrix, kMeansClustering, and Resample) call the special procedure MathFeedBackProc at regular intervals. The global variable ProcStat is automatically incremented and passed as a parameter to MathFeedBackProc.

The procedure MathFeedBackProc is in fact a procedure pointer which is initially set to NIL. The user may assign any procedure of the type FeedBackProcType to it.

Below you find short instructions how to implement a call-back routine:

1. Declare the routine which does the actual feedback (e.g. showing a progress bar, or something like that). This procedure has to have exactly the same declaration as FeedBackProcType. Don't forget to declare this procedure as far :

procedure ShowProgress (cnt: double); far;

begin      { here the display of the progress takes place }
Form1.Label1.Caption := IntToStr (cnt);
Application.ProcessMessages;
end;

Note, that the cnt parameter of the call back procedure passes the value of the variable ProcStat.

2. Before starting the time-consuming math procedure (FindCenters, in this example), assign the feedback procedure to the procedure variable MathFeedbackProc. You should also set the variable ProcStat to some defined value. After the completion of the time-consuming procedure you may reset the MathFeedbackProc to NIL.

...
ProcStat := 0;
MathFeedbackProc := ShowProgress;
FindCenters (Data, 1, Data.NrOfRows, NCenters, Centers, Md);
MathFeedbackProc := NIL;
...

Hint: Alternatively, you can use a timer interrupt which displays the contents of the variable ProcStat to display the progress of some calculation.

Example: This public variable is used in the following example program (see http://www.lohninger.com/examples.html for downloading the code): findcent



Last Update: 2015-Jun-11