Version 2.0
This release is an upgrade of the older version because of changes
in BDE laters releases.
Purpose and functionalities aren't changed.
The following description is the oldest one . . .
TCountTable is a component descending from TTable.
Like Paradox files, it allows an automatic autoincreasing field .
This field isn't editable and it's impossible to erase it.
This doesn't depend from the number of records,
i.e.
if you have 1000 rec.s and you erase 100 of them
the next number will be 1001 anyway, so it's impossible to have
2 rec.s
with the same number.
That's very useful for master-detail .
CntTable.DCR is built in 32 bits but the .RC file is given to you,
too.
So you can recompile it with any resources toolkit and make a .RES
file, then you just need to rename it from .RES to .DCR.
The counter is a longInt, stored in a one-record-file of longInt, with
the
same TableName but with extension *.MAX.
If this file is corrupted or doesn't exist, it's recreated like it
follows :
the index (if any) is temporarily removed to obtain the natural order
of
records; by a call to the 'Last' method, the cursor is set on the record
that
has certainly the highest number and it becomes the new counter.
**************************************************************************
All this happens just on some particular conditions, otherwise TCountTable
behaves like a normal TTable.
**************************************************************************
The condition making the difference is the presence of a particular
field
named FAutoFieldName in CntTable.pas composed like it follows:
the early five characters of TableName + '_NO'.
If TableName length is less than five -> TableName
+ '_NO'.
For example if TableName is MyTable.DBF, the field name will be 'MyTab_NO',
if TableName is MyT.DBF the field name will be 'MyT_NO'.
So, to obtain the autoincreasing counter, you just need in your table
a
field named like above.
Finally, if you call the CreateTable method without any field declared,
a dialogue allows you to add fields and indexes but this part is a
beta and
doesn't work so well.
|