![]() ![]() ![]() ![]() ![]() ![]() ![]() |
||
BDE API Examples (DbiSortTable)Sorts an opened or closed table, either into itself or into a destination table. There are options to remove duplicates, to enable case-insensitive sorts and special sort functions, and to control the number of records sorted.Example 1: Sort a table on a single field.Options are: Case Insensitive, Case Sensitive, Descending, and Ascending.This example uses the following input: SortTable(Table1, Table1.FieldByName('SortField'), False, sortDESCEND, L); NOTE: L is defined as a longint and specifies the amount of records to sort. Use TTable.RecordCount to sort the entire table. The function is defined as follows: procedure SortTable(Table: TTable; Field: TField; CaseInsensitive: boolean;
Order: SORTOrder; var SortNumber: longint);
var
Props: CURProps;
FieldNumber: word;
hDb: hDBIDb;
begin
if Table.Active = False then
raise EDatabaseError.Create('Table must be opened');
Check(DbiGetCursorProps(Table.Handle, Props));
if Props.bIndexed = True then
raise EDatabaseError.Create('No index can be active when sorting the table');
FieldNumber := Field.Index + 1;
Check(DbiGetObjFromObj(hDBIObj(Table.Handle), objDATABASE, hDBIObj(hDb)));
Table.Close;
try
Check(DbiSortTable(hDb, PChar(Table.TableName), Props.szTableType,
nil, nil, nil, nil, 1, @FieldNumber, @CaseInsensitive, @Order, nil,
False, nil, SortNumber));
finally
Table.Open;
end;
end;
| ||
|
DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains. |
||
| Trademarks & Copyright © 1998 Borland International, Inc. | ||