Topic: To Mathias

Hello Mathias

As a result of one of your answers to a question I had asked on this forum, you added a superb progress bar that progressed according to the loading of a CSV file.
How would you do with this same bar to illustrate the progress of a sql.db base (rather heavy) on a splash when opening a program?
Thank you for your answer

JB

Re: To Mathias

Hello dear Jean,


The way you build a TProgressBar depends on the action you are undertaking.


If you have a loop somewhere, it's easy to integrate the TProgressBar inside it (example attached).


If you are downloading a file, we lack some function integrated with Indy library : to do it the way it was intended, you need the OnWorkStart, OnWorkEnd properties we don't have, so you'll have to base your TProgressBar  on the size of the file you are downloading and cut it into chunks to count how fast they come in... Ideally, this process should be in a separated thread, but it's not implemented yet in MVD.


According to your question, I assume you are loading a SQL file on first start of a program, to populate the database before the user can use it.


Attached is how I do it with my own application :

1- check for existence of the SQL file to be loaded
2- if exists, then load the SQL commands in a TStingList
3-  execute each command line one by one with feedback to the user with TProgressBar  and message in a TLabel


The code is commented and you'll see that it's pretty straightforward. This is how I do it, there might be other approaches. Also, I only use very few TProgressBar properties, but you can play with the color of the TProgressBar , the style, the orientation and so on.


Have fun and do not hesitate to come back if I misunderstood your question.


Cheers



Mathias


PS : I used beta 2.8 for this build, but might work with official 2.7

Post's attachments

Attachment icon ProgressBar.zip 352.94 kb, 473 downloads since 2016-11-12 

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: To Mathias

Hello Mathias

Thanks for your help.
Very useful !
I understand better the principle of using a Progress Bar to load a file.
This works fine when loading (or importing) a TXT or CSV file.
But much less if I use the progress bar to load the sql.db file as soon as the application is launched.

There I have an error message: SQLite format 3
Probably because it's a binary file that can only be read line by line as in the case of a text file.
Too bad ! It is still a nice thing to follow the loading of an imported file (CSV or Txt)

Thanks again Mathias !

JB