program PutDate;
uses PXEngine, WinCrt;

const TableName = 'Table';

var   PxErr: Integer;
      TblHandle: TableHandle;
      RecHandle: RecordHandle;
      FldHandle: FieldHandle;
      Month, Day, Year: Integer;
      Date: Longint;

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

begin
  PX(PXWinInit('MyApp', pxShared));
  Month := 1; Day := 27; Year := 1990;

  PX(PXTblOpen(TableName, TblHandle, 0, False));
  PX(PXRecBufOpen(TblHandle, RecHandle));
  PX(PXFldHandle(TblHandle, 'Date Field', FldHandle));
  PX(PXDateEncode(Month, Day, Year, Date));

  (* Update record with new date *)
  PxErr := PXPutDate(RecHandle, FldHandle, date);
  if PxErr <> PxSuccess then
    Writeln(PxErrMsg(PxErr))
  else PX(PXRecUpdate(TblHandle, RecHandle));

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