Program EntrySample; var Field : String[10]; LowEnd,HighEnd : Real; Result,Value, Place,FieldSize,Times : Integer; Cursor,Ch : Char; RangeOK : Boolean; procedure InputField; label Bypass; begin Field := ''; Place := 0; Repeat Read(Kbd,Ch); If Length(Field)<=FieldSize then begin Case Ch of #8 : begin {BackSpace key} If Place=0 then begin {avoid backspacing beyond} Write(Trm,Chr(8)); {beginning of field } Write(' '); end else begin Delete(Field,Place,1); {destructive backspace} Place := Place-1; Write(Trm,Chr(8)); Write(Cursor); Write(Trm,Chr(8)); end; end; #127 : begin; {Delete Key} If Place=0 then begin {avoid backspacing beyond} Write(Trm,Chr(8)); {beginning of field again} Write(' '); end else begin Delete(Field,Place,1); {destructive backspace} Place := Place-1; Write(Trm,Chr(8)); Write(Cursor); Write(Trm,Chr(8)); end; end; #13 : begin {Carraige Return--End of input} GoTo Bypass; {for this field } end; else If Length(Field) Chr(13) then Write(Chr(7)); {Ring bell at terminal if at end of} end; {field and no RETURN key pressed } ByPass: end; end; Until Ch=Chr(13); end; procedure StripBlanks; {don't use on Alpha-numeric fields...} {blanks there may be valid } begin Repeat Place := Pos(' ',Field); Delete(Field,Place,1); Place := Pos(' ',Field); Until Place=0; end; procedure RangeCheck; begin Result := 0; {initialize error code} StripBlanks; {from FLDINPUT.PAS - pull out blanks} Val(Field,Value,Result); {convert Field to a Number} If Result <> 0 then begin {look for non-numeric characters} Result := 0; {reset result code} RangeOK := False; Write(Chr(7)); GoToXY(1,23); ClrEol; WriteLn('Input must be numeric. '); Write('Press any key to continue... '); Read(Kbd,Ch); GoToXY(1,23); ClrEol; GoToXY(1,24); ClrEol; end else begin If (Value < LowEnd) or (Value > HighEnd) then begin Write(Chr(7)); RangeOK := False; GoToXY(1,23); ClrEol; WriteLn('Value not in allowable range. '); Write('Press any key to continue... '); Read(Kbd,Ch); GoToXY(1,23); ClrEol; GoToXY(1,24); ClrEol; end else begin RangeOK := True; end; {checking range} end; {checking result code} end; {of RangeCheck} begin {little sample program} ClrScr; Write('What do you use to delineate fields? (e.g., "_") :'); Read(Cursor); ClrScr; GoToXY(30,4); Write('Entry Test'); GoToXY(1,6); Write('Alpha Data: '); FieldSize := 8; GoToXY(20,6); For Place := 1 to FieldSize do begin Write(Cursor); end; GoToXY(20,6); InputField; GoToXY(20,6); ClrEol; WriteLn(Field); Field := ''; Repeat GoToXY(1,8); Write('Enter a number between 1 and 1000 : '); FieldSize := 4; LowEnd := 1; HighEnd := 1000; GoToXY(40,8); For Place := 1 to FieldSize do begin Write(Cursor); end; GoToXY(40,8); InputField; StripBlanks; RangeCheck; Until RangeOK; Field := ''; GoToXy(20,1); Write('Press any key to continue...'); Read(Kbd,Ch); ClrScr; end.