Delphi Examples: DbiGetRecord

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Delphi Examples: DbiGetRecord

Return to chapter overview

Get the record ID of the current record in the specified TTable.

This example uses the following input:

 fDbiGetRecord(Table1, Num);

 

The procedure is:

procedure fDbiGetRecord(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));

   Check(DbiGetRecord(Handle, dbiNOLOCK, nil, @RP));

  if (StrComp(CP.szTableType, szDBASE) = 0) then

     RecID := RP.iPhyRecNum

  else

    if (StrComp(CP.szTableType, szPARADOX) = 0) then

       RecID := RP.iSeqNum

    else

       // raise exception if it's not a Paradox or dBASE table

      raise EDatabaseError.Create('Not a Paradox or dBASE table');

end;

end;