2009. november 29., vasárnap

Determining the record number in a dBASE/Paradox table


Problem/Question/Abstract:

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:

function FindRecordNumber(aDataSet: TDataSet): longint;
var
  cP: CurProps;
  rP: RECProps;
  DBRes: DBiResult;
begin
  {Return 0 if dataset is not Paradox or dBase}
  Result := 0;

  with aDataset do
  begin
    if state = dsInactive then
      exit;

    {we need to make this call to grab the cursor's iSeqNums}
    DBRes := DBiGetCursorProps(Handle, cP);
    if DBRes <> DBIERR_NONE then
      exit;

    {synchronize the BDE cursor with the dataset's cursor}
    UpdateCursorPos;

    {fill rP with the current record's properties}
    DBRes := DBiGetRecord(Handle, DBiNOLOCK, nil, @rP);
    if DBRes <> DBIERR_NONE then
      exit;

    {what kind of dataset are we looking at?}
    case cP.iSeqNums of
      0: result := rP.iPhyRecNum; {dBase}
      1: result := rP.iSeqNum; {Paradox}
    end;
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése