home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol023 / getint.lib < prev    next >
Text File  |  1984-04-29  |  632b  |  29 lines

  1.  
  2. {    GETINTEGER
  3.  
  4.     The calling program must pass a MSG to be issued in the input
  5.     prompt and MIN and MAX values for the returned value.
  6.     Function will not exit until entered data is within range.
  7.  
  8.     Requires PROMPT.
  9. }
  10.  
  11. FUNCTION getinteger (min, max : integer; msg : string255) : integer;
  12.  
  13. VAR    data : integer;
  14.  
  15. begin
  16.     repeat
  17.         prompt (msg);
  18.         readln (data);
  19.         if (data>max) then
  20.             writeln (' *** Value of ',msg,' cannot exceed ',
  21.                 max:1,' ***')
  22.         else if (data<min) then
  23.             writeln (' *** Value of ',msg,' must exceed ',
  24.                 min:1,' ***')
  25.     until (data <= max) and (data >= min);
  26.     getinteger := data
  27. end;
  28.  
  29.