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 2 function FindRecordNumber(aDataSet: TDataSet): longint;
3 var4 cP: CurProps;
5 rP: RECProps;
6 DBRes: DBiResult;
7 begin8 {Return 0 if dataset is not Paradox or dBase}9 Result := 0;
10 11 with aDataset do12 begin13 if state = dsInactive then14 exit;
15 16 {we need to make this call to grab the cursor's iSeqNums}17 DBRes := DBiGetCursorProps(Handle, cP);
18 if DBRes <> DBIERR_NONE then19 exit;
20 21 {synchronize the BDE cursor with the dataset's cursor}22 UpdateCursorPos;
23 24 {fill rP with the current record's properties}25 DBRes := DBiGetRecord(Handle, DBiNOLOCK, nil, @rP);
26 if DBRes <> DBIERR_NONE then27 exit;
28 29 {what kind of dataset are we looking at?}30 case cP.iSeqNums of31 0: result := rP.iPhyRecNum; {dBase}32 1: result := rP.iSeqNum; {Paradox}33 end;
34 end;
35 end;