Home How to display progress of the TFDScript execution using TProgressBar?
Reply: 1

How to display progress of the TFDScript execution using TProgressBar?

Dalibor Marković
1#
Dalibor Marković Published in 2018-02-09 00:15:01Z

I have some script in some file "MyScript.sql" On the form I have my TProgressBar. I want to read script with TFDScript and move progressbar according to the script.

My code is

    Var

      Lista: TStringList; // SQL DDL list for creating table and populate table
      I: Integer;
    Begin

  With FDConn Do    //FDConn is my FaireDac connection
  Begin
    LoginPrompt := False;
    With Params Do
    Begin
      Clear;
      DriverID := 'SQLite';
      Database := 'MyDatabase.sdb';
      LoginPrompt := False;
    End;

    Lista := TStringList.Create;
    Lista.Clear;
    Try

      FDScript.ValidateAll;   //FDScript is TFDScript and prgBar is TProgressBar
      prgBar.Max := FDScript.TotalJobSize - 1;
      prgBar.Update;

      Lista.Clear;
      Lista.LoadFromFile('MyScript.sql');

// Now how I can read script 1 line by 1 line and move progress bar with
prgBar.StepIt;
prgBar.Update;`
Victoria
2#
Victoria Reply to 2018-02-09 16:43:31Z

You can handle the OnProgress event and read there e.g. TotalJobSize property to determine the number of bytes to proceed and TotalJobDone to get number of bytes processed. For example:

procedure TForm1.FDScript1Progress(Sender: TObject);
begin
  ProgressBar1.Max := TFDScript(Sender).TotalJobSize;
  ProgressBar1.Position := TFDScript(Sender).TotalJobDone;
end;

If you were having progress bar control with progress value setup by percentage, you'd better read the TotalPct10Done property.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302364 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO