program RecNFlds;
uses PXEngine, WinCrt;

const TableName = 'Table';

var   PxErr: Integer;
      TblHandle: TableHandle;
      NFlds: Integer;

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

begin
  PX(PXWinInit('MyApp', pxShared));
  PX(PXTblOpen(TableName, TblHandle, 0, False));

  (* Determine number of fields in table *)
  PxErr := PXRecNFlds(TblHandle, NFlds);
  if PxErr <> PxSuccess then
    Writeln(PxErrMsg(PxErr))
  else Writeln('Number of fields in table ', TableName, ' is: ', NFlds);

  PX(PXTblClose(TblHandle));
  PX(PXExit);
end.
