program KeyNFlds;
uses PXEngine, WinCrt;

const TableName = 'Table';

var   PxErr: Integer;
      TblHandle: TableHandle;
      NKeyFlds: Integer;

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

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

  (* Determine how many fields are in index *)
  PxErr := PXKeyNFlds(TblHandle, NKeyFlds);
  if PxErr <> PxSuccess then
    Writeln(PxErrMsg(PxErr))
  else Writeln('Number of fields in key: ', NKeyFlds);

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