program GetAlpha;
uses PXEngine, WinCrt;

const TableName = 'Table';

var   PxErr: Integer;
      TblHandle: TableHandle;
      RecHandle: RecordHandle;
      FldHandle: FieldHandle;
      AValue: array[0..255] of char;

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

begin
  PX(PXWinInit('MyApp', pxShared));
  PX(PXTblOpen(TableName, TblHandle, 0, False));
  PX(PXRecBufOpen(TblHandle, RecHandle));
  PX(PXFldHandle(TblHandle, 'Alpha Field', FldHandle));
  PX(PXRecGet(TblHandle, RecHandle));

  (* Get an alphanumeric value out of a field *)
  PxErr := PXGetAlpha(RecHandle, FldHandle, 255, @AValue);
  if PxErr <> PxSuccess then
    Writeln(PxErrMsg(PxErr))
  else Writeln('Field number ', FldHandle, ' contents: ', AValue);

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