program FieldName;
uses PXEngine, WinCrt;

const TableName = 'Table';

type NameString = array[0..24] of char;

var   PxErr: Integer;
      TblHandle: TableHandle;
      FldHandle: FieldHandle;
      FldName: NameString;

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

begin
  PX(PXWinInit('MyApp', pxShared));

  FldHandle := 1;
  PX(PXTblOpen(TableName, TblHandle, 0, False));

  (* Get field name for first field in table *)
  PxErr := PXFldName(TblHandle, FldHandle, 20, @FldName);
  if PxErr <> PxSuccess then
    Writeln(PxErrMsg(PxErr))
  else Writeln('Field handle ',FldHandle, ' has field name ', FldName);

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