program BufCopy;
uses PXEngine, WinCrt;

const TableName = 'Table';

var   PxErr: Integer;
      TblHandle: TableHandle;
      SrcRecHandle,
      DestRecHandle: RecordHandle;

procedure PX(Code : integer);
begin
  writeln(PXErrMsg(Code));
end;

begin
  PX(PXWinInit('MyApp', pxShared));
  PX(PXTblOpen(TableName, TblHandle, 0, False));
  PX(PXRecBufOpen(TblHandle, SrcRecHandle));
  PX(PXRecBufOpen(TblHandle, DestRecHandle));
  PX(PXRecGet(TblHandle, SrcRecHandle));

  (* Copy source record handle to destination record handle *)
  PxErr := PXRecBufCopy(SrcRecHandle, DestRecHandle);
  if PxErr <> PxSuccess then
    Writeln(PxErrMsg(PxErr));

  PX(PXRecBufClose(SrcRecHandle));
  PX(PXRecBufClose(DestRecHandle));
  PX(PXTblClose(TblHandle));
  PX(PXExit);
end.
