Recent

Author Topic: (Solved) Pack Table  (Read 2011 times)

Petrus Vorster

  • Full Member
  • ***
  • Posts: 171
(Solved) Pack Table
« on: September 15, 2025, 03:54:29 pm »
Hi All

I have a little separate tool to run a packtable on a few DBF tables on a project.
That works 100%.

I am curious that i just cannot get this to work or the Close event of the main form.
There are a number of controls and components attached to that database.
E.g. DBgrids, Dbnavigators etc.

I know that one need to probably Close the DBF, then open Exclusive, but I have tried to disable all the controls (DBF1.disablecontrols) , setting active to off, and so forth, but I get errors of all kinds.
Some process is still busy and I get all kinds of errors on my many attempts.

Its not something that needs to run daily. I will put in a counter in the ini file for every 10 startups or so.
What am I missing here again?

Thanks for all the help.

Peter
« Last Edit: October 01, 2025, 08:51:34 am by Petrus Vorster »

silvercoder70

  • Full Member
  • ***
  • Posts: 200
    • Tim Coates
Re: Pack Table
« Reply #1 on: September 16, 2025, 11:39:09 pm »
Hi,

From your post you want to do some maintenance when the program closes. Without knowing the size of the DB what time would that add to the shutdown.

If you are using a counter as suggested, why not push it to the front before the user connects to the database, and then you are guaranteed access. I would also ask the user if they want to perform database maintenance now? If yes, go ahead and do that else ...
🔥 Pascal Isn’t Dead -> See What It Can Do: @silvercoder70 on YouTube

Zvoni

  • Hero Member
  • *****
  • Posts: 3138
Re: Pack Table
« Reply #2 on: September 17, 2025, 08:32:54 am »
Why not just call a TProcess on that separate Tool as the last line before Application.Terminate?
Shoot and forget?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

wp

  • Hero Member
  • *****
  • Posts: 13213
Re: Pack Table
« Reply #3 on: September 17, 2025, 12:43:42 pm »
From your post you want to do some maintenance when the program closes. Without knowing the size of the DB what time would that add to the shutdown.

If you are using a counter as suggested, why not push it to the front before the user connects to the database, and then you are guaranteed access. I would also ask the user if they want to perform database maintenance now? If yes, go ahead and do that else ...
+1

I am always confused when an application is not closing immediately and does not tell me why.

Petrus Vorster

  • Full Member
  • ***
  • Posts: 171
Re: Pack Table
« Reply #4 on: September 25, 2025, 03:31:58 pm »
Hi All

Thank you for the responses. I was out for a week or two.

That Tprocess... I have never used that.
Could you show me how that works?

Thank you

-Peter

avra

  • Hero Member
  • *****
  • Posts: 2566
    • Additional info
Re: Pack Table
« Reply #5 on: September 27, 2025, 03:35:47 pm »
DBF is not great. Indexes can be corrupted on unexpected shutdowns. Back in the days to protect integrity, the last thing my apps did was to delete a flag file which was created during app init. If that flag was found during app init, I knew there was unexpected shutdown and I reindexed all DBFs. That helped, but was a lengthy process. You can add packing tables here, or when 10th app start is detected.

Btw, using SQLite would be much better choice.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Petrus Vorster

  • Full Member
  • ***
  • Posts: 171
Re: Pack Table
« Reply #6 on: October 01, 2025, 08:49:13 am »
Hi Avra.

I came from flat files in Basic.
I dabbed into simple Sqlite over there, but still have to get that fully functional in Pascal.

I use the DBF in the simplest of ways. Straigtforward rows of info. no indexes of any kind since my largest volume of data will never exceed 5000 rows.
I do enjoy the controls that comes with Pascal, and the nice tools you have here.

Soon, when i have nothing to work on, I will have to get Zeos going and get that right.

Its been an awesome experience picking this up.

-Peter

 

TinyPortal © 2005-2018