Author: Tomas Rutkauskas
Determining the record number in a dBASE/Paradox table
Answer:
The following procedure determines the physical number of the current record
in a dBase or Paradox table:
1 function FindRecordNumber(aDataSet: TDataSet): longint;
2 var3 cP: CurProps;
4 rP: RECProps;
5 DBRes: DBiResult;
6 begin7 {Return 0 if dataset is not Paradox or dBase}8 Result := 0;
9 10 with aDataset do11 begin12 if state = dsInactive then13 exit;
14 15 {we need to make this call to grab the cursor's iSeqNums}16 DBRes := DBiGetCursorProps(Handle, cP);
17 if DBRes <> DBIERR_NONE then18 exit;
19 20 {synchronize the BDE cursor with the dataset's cursor}21 UpdateCursorPos;
22 23 {fill rP with the current record's properties}24 DBRes := DBiGetRecord(Handle, DBiNOLOCK, nil, @rP);
25 if DBRes <> DBIERR_NONE then26 exit;
27 28 {what kind of dataset are we looking at?}29 case cP.iSeqNums of30 0: result := rP.iPhyRecNum; {dBase}31 1: result := rP.iSeqNum; {Paradox}32 end;
33 end;
34 end;