BFC_FileCheck

Description

At first i wish to say that the author is NOT responsible for any damage that is caused by using this component. If you look for somebody to blame, blame yourself or don't use this component.

 

This is a Delphi component designed for

The purpose is to first make a DBI-file from the datafile. This DBI-file (DBI stands for DataBase Inifile) holds the description of each field and index. Currently referential integrity and passwords are NOT supported. An EXE-demo program for making these DBI-files is provided, but you can easily write your own.

Distribute these DBI-files together with your application.

The way i use it is that everytime my end-user starts his application i do a version-check. That is, i check the version of the executable with the previous version stored in a inifile or registry. When the versions are not the same use the components startcheck method with the property CtrlStruct set to True and property FileName set to *.DB (I use paradox-files) The structure of every datafile will be checked with the structure described in the DBI-file. If the structure does not match, a conversion will be made.

Packing and Reindexing don't need a DBI-file.

Both DbaseIV and Paradox-files are supported. The extention of the filename will be used to determine the type of datafile.

 

Properties

BusyLabel   Declaration
property BusyLabel: TLabel;

Description
When converting, packing, checking, ... a datafile the BFC_Filecheck-component generates messages saying what's going on and what he is doing. If you want your end-user to see these messages, you can provide the name of the TLabel-component in which the message will be displayed.

CtrlStruct   Declaration
property CtrlStruct: boolean;

Description
With this property set to True the StartCheck-method will compare the structure of the files set in the FileName-property with the structure described in the DBI-file. Both fields and indexes will be checked. If there is a mismatch a conversion will be made. These are the steps for the conversion :

  • All the original indexes will be dropped.
  • The original datafile and memofile will be renamed to old<datafile>. The old<datafile>-name will be a filename in the format 8.3.
  • A new, empty datafile will be created according to the description found in the DBI-file.
  • All indexes will be build.
  • The data from the <old>datafile will be read into the new datafile. Only data from fields with the same name in both the datafiles will be read. If you want to recover data from a field you will have to keep the same fieldname. You can however change the type and size. You can convert an integer-field to a string-field or change the size from a string-field from 50 to 30. BFC-Filecheck will try to make the conversion. If this fails the data for that field will be LOST. So test this first before sending anything to your customer.
  • If something fails during the conversion, the component will try to recover the old<datafile> without the indexes.
DBIDirectory   Declaration
property DBIDirectory: string;

Description
The place in which the DBI-files will be stored (when making them) or will be searched for (when checking). If this directory is empty, BFC_Filecheck will use the directory the executable is in. If a directory is provided, that one will be used. If the provided directory does not exist, it will be created without asking for it.

Filename   Declaration
property Filename: string;

Description
Filename(s) that need to be handled. Wilcards can be used.

MakeIni   Declaration
property MakeIni: boolean;

Description
When this property is set to True, the method StartCheck will make a DBI-file for each file named in the Filename-property.

NewFile   Declaration
property NewFile: boolean;

Description
When this property is set to True, the method StartCheck will make a new datafile for each file named in the FileName-property. All data in the existing datafiles is LOST PERMANENT. If you want to keep your data set the RebuildFile-property to true and this property to false.

NewIndex   Declaration
property NewIndex: boolean;

Description
When this property is set to True, the method StartCheck will make a new indexfile for each file named in the FileName-property. The existing indexes will be dropped and recreated from scratch. This will solve the error-message 'Index out of date'.

Pack   Declaration
property Pack: boolean;

Description
Set this property to True when you want to pack the datafile(s) described in the property FileName. DBI-files are not used here.

ProgramName   Declaration
property ProgramName: string;

Description
You can provide the name of the application here. The name will be stored in the DBI-file together with the VersionNumber. This property is optional and will be used for information purposes only.

ProgramVersion   Declaration
property ProgramVersion: string;

Description
You can provide the version of the application here. The name will be stored in the DBI-file together with the ProgramName. This property is optional and will be used for information purposes only.

Progressbar   Declaration
property Progressbar: TProgressBar;

Description
When converting, packing, checking, ... a datafile the BFC_Filecheck-component uses a callback provided through the BDE. This callback provides messages and procentages indication the progress. These messages and procentages are converted by the BFC-component is such a way that they can be used to give the progress of the action that is executed. When you have a TProgressbar somewhere available you can provide the name of the TProgressbar in this property. The BFC-Filecheck-component will update the progressbar.

RebuildFile   Declaration
property RebuildFile: boolean;

Description
This property will rebuild the datafile(s) provides in the FileName-property using the DBI-file. This is similar to the CtrlStruct-property except that the file will always be rebuild. Setting this property to true does not only rebuild the datafile but also the indexfile(s).

RebuildIndex   Declaration
property RebuildIndex: boolean;

Description
Set this property to True when you want to reindex the datafile(s) described in the property FileName. DBI-files are not used here.

 

Methods

CheckFile   Declaration
procedure CheckFile(Filename: String; Pack, RebuildIndex, NewIndex, RebuildFile, NewFile, CtrlStruct, MakeIni: Boolean; Version, Programname: String; PrgBar: TProgressBar; Busy: TLabel);

Description
The Checkfile-method is only provided for backward-compatability. with this method you can invoke the action with just one procedure instead of setting each property and invoking the StartCheck-method. Basically it does the same.

StartCheck

 

  Declaration
procedure StartCheck;

Description
Use this method to start checking the files described in the FileName}-property. The actions that will be taken depend on the settings of the properties.

SetInit   Declaration
procedure SetInit;

Description
Use this method to initialize all the properties to 'False' (MakeIni, NewFile, RebuildFile, ...)

SetInitPack   Declaration
procedure SetInitPack;

Description
Use this method to initialize all the properties to 'False' (MakeIni, NewFile, RebuildFile, ...) except the Pack-property

SetInitRebuildIndex   Declaration
procedure SetInitRebuildIndex;

Description
Use this method to initialize all the properties to 'False' (MakeIni, NewFile, RebuildFile, ...) except the RebuildIndex-property

SetInitNewIndex   Declaration
procedure SetInitNewIndex;

Description
Use this method to initialize all the properties to 'False' (MakeIni, NewFile, RebuildFile, ...) except the NewIndex-property

SetInitRebuildFile   Declaration
procedure SetInitRebuildFile;

Description
Use this method to initialize all the properties to 'False' (MakeIni, NewFile, NewIndex, ...) except the RebuildFile-property

SetInitNewFile   Declaration
procedure SetInitNewFile;

Description
Use this method to initialize all the properties to 'False' (MakeIni, NewFile, RebuildFile, ...) except the NewFile-property

SetInitCtrlStruct   Declaration
procedure SetInitCtrlStruct;

Description
Use this method to initialize all the properties to 'False' (MakeIni, NewFile, RebuildFile, ...) except the CtrlStruct-property

SetInitMakeIni   Declaration
procedure SetInitMakeIni;

Description
Use this method to initialize all the properties to 'False' (NewIndex, NewFile, RebuildFile, ...) except the MakeIni-property