Creating dBASE Expression Indexes In Delphi Applications
========================================================
dBASE indexes can be created programmatically in Delphi
applications,either as a new table is being created (CreateTable
method of the TTable component) or by adding an index to an existing
table.
Creating an index as part of a new table being created is a
matter of calling the Add method for the IndexDefs property of the
TTable. A special consideration that the index options must include
the option ixExpression. This index option is unique to dBASE ndexes,
and should only be used with dBASE expression indexes. For example:
with Table1 do begin
Active := False;
DatabaseName := 'Delphi_Demos';
TableName := 'CustInfo';
TableType := ttdBASE;
with FieldDefs do begin
Clear;
Add('LastName', ftString, 30, False);
Add('FirstName', ftString, 20, False);
end;
with IndexDefs do begin
Clear;
Add('FullName', 'LastName + FirstName', [ixExpression]);
end;
CreateTable;
end;
Adding an index to an existing table is accomplished by calling
the Add-Index method of the TTable. Again, the index options must
include the TIndexOptions value ixExpression.
Table1.AddIndex('FullName', 'LastName + FirstName', [ixExpression]);