home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / pascal / IOFUNC.ZIP / ZKEYS.LIB < prev    next >
Encoding:
Text File  |  1986-04-12  |  3.2 KB  |  86 lines

  1. {           ╔═══╦══════════════════════════════════════════════╦═══╗
  2.             ║   ║         Pascal Library by Scott Wade         ║   ║
  3.             ║   ║           715 FM 1959      Apt 310           ║   ║
  4.             ║   ║           Houston, TX 77034                  ║   ║
  5.      ┌──────╨───╨──────────────────────────────────────────────╨───╨──────┐
  6.      │  This  group of routines is contributed to public domain,  and no  │
  7.      │  one can possibly get any commercial value out of them since they  │
  8.      │  must be used in other programs. I require that if these are used  │
  9.      │  as is in  any  program,  that this banner remain with the source  │
  10.      │  code of the program.  I would appreciate any comments or sugges-  │
  11.      │  tions on improvements, & am curious to hear how these are used.   │
  12.      │  You can leave a message for me on these BBS's:                    │
  13.      │          Ziggy's  821-1391         ScoreBoard  583-7848            │
  14.      │          TBL-COMM 661-9040         Test-Mode   660-9252            │
  15.      └────────────────────────────────────────────────────────────────────┘
  16.  
  17. ZKEYS.LIB v1.1
  18.         keyboard input reader & type converter library.
  19.  v1.1:  9/27/85 : Zstring, a useless proc, was removed. code was cleaned up
  20.         some. }
  21.  
  22. procedure ZStripBlanks(var Blankit : Buffer);{
  23.    This strips the leading blanks off of strings so i can convert them to
  24.    real numbers, since the inadequecies of the VAL proc won't allow them.}
  25. begin
  26.    BlankIt := ' ' + BlankIt ;
  27.    Repeat
  28.      BlankIt := copy( BlankIt ,2, Length(BlankIt)-1)
  29.    Until (copy(BlankIt,1,1) <> ' ');
  30. end{ StripBlanks };
  31.  
  32. procedure ZGetKey;
  33. begin
  34.    Write('Press a key to continue...');
  35.    Repeat Until Keypressed ;
  36.    Writeln;
  37. end{ ZGetKey };
  38.  
  39. procedure ZInt(var KeyInt : integer ; PromptLin : Buffer );{
  40.  
  41. KeyInt is the value keyed in & will be returned to the caller. PromptLin is the
  42. prompt set right before calling this. The prompt is printed then input is
  43. called for. If the input is invalid, an errmsg is printed and input is asked
  44. for  again.}
  45.  
  46. var
  47.    Keystr  : Buffer;
  48.    Errf, I : Integer ;
  49. begin
  50. REPEAT
  51.    write( PromptLin);
  52.    Readln( KeyStr);
  53.    ZStripBlanks ( KeyStr);
  54.    ErrF := 0;
  55.    Val( KeyStr, KeyInt, ErrF );
  56.    If ErrF > 0 then begin
  57.       For I := 1 to ErrF + Length( PromptLin) - 1 do write(' ');
  58.       writeln( '^ Err - Not Integer! Please try again.');
  59.    end{ If ErrF };
  60. UNTIL ErrF = 0 ;
  61. end{ ZInt };
  62.  
  63. procedure ZReal(var KeyReal : Real ; PromptLin : Buffer );{
  64. KeyReal is the value keyed in & will be returned to the caller. PromptLin is
  65. the prompt set right  before calling this.  The prompt is printed then input
  66. is called for.  If the input is  invalid, an  errmsg is printed and input is
  67. asked for  again.}
  68.  
  69. var
  70.    KeyStr  : Buffer ;
  71.    Errf, I : Integer  ;
  72. begin
  73. REPEAT
  74.    write( PromptLin);
  75.    Readln( KeyStr);
  76.    ZStripBlanks( KeyStr);
  77.    ErrF := 0;
  78.    Val( KeyStr, KeyReal, ErrF );
  79.    If ErrF > 0 then begin
  80.       For I := 1 to ErrF + Length( PromptLin) - 1 do write(' ');
  81.       writeln( '^ Err - Not A Real Number! Please try again.');
  82.    end{ If ErrF };
  83. UNTIL ErrF = 0 ;
  84. end{ ZReal };
  85. { end  ZKEYS.LIB
  86. *****************************************************************************}