program testgetField;
{--------------------------------------------------------------------------}
{  This program is used to test the GetField assembly routine!             }
{--------------------------------------------------------------------------}

type
  str10  = string[10];
  str20  = string[20];
  str255 = string[255];
  Option_Type = set of 0..7;

var
  Ibuf : str255;
  KeyVal : integer;
  Legal  : str255;
  Opts   : Option_Type;
  Attrib : integer;
  IRow   : integer;
  ICol   : integer;
  ISize  : integer;

procedure GetField(var KeyVal       : integer;
                   var Legal        : str255;
                   var Ibuf         : str255;
                       Atrib,
                       Row,Col,Size : integer;
                       Options      : Option_Type);

  external 'Getfield.bin';

begin
  ClrScr;
{----------------------------------------------------------------------------
  Opts = [1]   => test only conversion to upper-case
  Attrib = $30 => lt Blue background - black foreground
  IRow   =  10 => start input area at row 10
  ICol   =   1 => start input area in column 1
  ISize  =   5 => input area has maximum size of 5 characters
  Legal  =  '' => no check is done for legal char's when legal is zero length
 ----------------------------------------------------------------------------}
  Legal := '';
  Opts := [1];
  Attrib := $30;
  IRow := 5;
  ICol := 1;
  ISize := 5;
  Gotoxy(1,3);
  writeln('**** Test of input & automatic conversion to uppercase ****');
  write('Enter anything you like: (it will be converted to uppercase)');
  GetField(KeyVal,Legal,Ibuf,Attrib,IRow,ICol,ISize,Opts);
  writeln;
  writeln('Did you notice that couldn''t type past the end of the field?');
  writeln('Value of last key pressed was: ',KeyVal);
  Writeln('Number of characters in field is: ',ord(Ibuf[0]));
  writeln('Content of Ibuf is: ',Ibuf);
  writeln;

{----------------------------------------------------------------------------
  Opts = [7]   => use prior value of Ibuf
  Attrib = $1A => Blue background - green foreground
  IRow   = wherey => start input area in current row
  ICol   = wherex => start input area in current column
  ISize  =   5 => input area has maximum size of 5 characters
  Legal  =  '' => no check is done for legal char's when legal is zero length
 ----------------------------------------------------------------------------}
  writeln('For those of you without color monitors, this is a BLUE field,');
  writeln('with a green lettering!');
  writeln('Try using the left and right arrows, and the Del key:');
  writeln('(When you''re done, trying pressing [ESCAPE]...)');
  write('Try editing what you entered in the above => ');
  GetField(KeyVal,Legal,Ibuf,$1a,wherey,wherex,5,[7]);
  writeln;
  writeln('Value of last key pressed was: ',KeyVal);
  Writeln('Number of characters in field is: ',ord(Ibuf[0]));
  writeln('Content of Ibuf is: ',Ibuf);
  writeln;
{----------------------------------------------------------------------------
  Opts = [1,5]      => Upper-case,Auto-exit
  Attrib = $34      => grey background - red foreground
  IRow   = wherey+1 => start input area in next row downward
  ICol   = wherex   => start input area in column 1
  ISize  =   1      => input area has maximum size of 1 character
  Legal  =  'YN'    => allow only Y or N from keyboard!
 ----------------------------------------------------------------------------}
  Legal := 'YN';
  write('Do you like this so far? {Y/N} ');
  GetField(KeyVal,Legal,Ibuf,$34,wherey,wherex,1,[1,5]);
  writeln;
  writeln('Did you notice that you did NOT have to press [ENTER]?');
  writeln('This just demonstrated the AUTO-EXIT feature!');
  writeln;
  writeln('Value of last key pressed was: ',KeyVal);
  Writeln('Number of characters in field is: ',ord(Ibuf[0]));
  writeln('Content of Ibuf is: ',Ibuf);
  writeln;
  writeln('All key codes for function keys, etc. are returned as integer');
  writeln('values - with 256 added to the value for the "extended" keys.');
  writeln('For example, F1 = 27 59 is returned as 256+59 => 315');
  writeln;
  writeln('-----------------------------');
  writeln('|  End of sample program!   |');
  writeln('-----------------------------');
end.
