home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-2.ZIP / GFUNC / GETDIGIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-30  |  753 b   |  43 lines

  1. /*
  2.  * getdigit.c
  3.  * contains: getdigit()
  4.  *
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include "ibmkeys.h"
  9. #include "gfuncts.h"
  10.  
  11. /*
  12.  *  char
  13.  * getdigit(void)
  14.  *
  15.  * ARGUMENT
  16.  *  (none)
  17.  *
  18.  * DESCRIPTION
  19.  *  Processing is suspended awaiting a keystroke.  If the keystroke is a
  20.  *  digit or ESCape, the ASCII value is returned.  If the keystroke is a
  21.  *  digit it is output via putchar() also.
  22.  *
  23.  * RETURNS
  24.  *  Ascii value of numeric key entry or ESC (0x1b)
  25.  *
  26.  * AUTHOR
  27.  *   Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  28.  */
  29. char GF_CONV getdigit()
  30. {
  31.     unsigned c;
  32.  
  33.     while (FOREVER) {
  34.         c = getkey();
  35.         if(gisdigit((char)c)) {
  36.             putchar((char)c);
  37.             return (char)c;
  38.         }
  39.         if(c==ESC)
  40.             return (char)c;
  41.     }
  42. }
  43.