Retrieve the sequence number of the current record associated with a cursor:
The following procedure returns the record ID of the current record in ATable. If ATable is a Paradox table, it uses DbiGetSeqNo() to obtain the sequence number. If ATable is a dBASE or FoxPro table, it uses record properties provided by DbiGetRecord to obtain the physical record number. If the table is SQL or text, an exception is raised. The record ID is returned in the RecID parameter, which is passed by reference.
procedure GetRecordID(ATable: TTable; var RecID: Longint);
var
CP: CURProps;
RP: RECProps;
begin
with ATable do begin
{ Make sure it is a Paradox table! }
UpdateCursorPos; // sync BDE with Delphi
{ Find out if table support Seq nums or Physical Rec nums }
Check(dbiGetCursorProps(Handle, CP));
case CP.iSeqNums of
0 : begin // dBASE tables support Phy Rec Nums
Check(DbiGetRecord(Handle, dbiNOLOCK, nil, @RP));
RecID := RP.iPhyRecNum;
end;
1 : Check(DbiGetSeqNo(Handle, RecID)); // Paradox tables support Seq Nums
else
{ raise exception if it's not a Paradox or dBASE table }
raise EDatabaseError.Create('Not a Paradox or dBASE table');
end;
CursorPosChanged; // sync Delphi with BDE
end;
end;