home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / msj / msjv2_5 / msc5 / message.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-02  |  1.2 KB  |  50 lines

  1. /*
  2.  
  3. Figure 6
  4. ========
  5.  
  6. */
  7.  
  8. /***************************************************************
  9. * Message
  10. *
  11. * DESCRIPTION:  Display the message text at the specified
  12. *  screen location (row, col).  If wait has a non-zero value,
  13. *  wait for the user to press a key.  When the user complies,
  14. *  grab the character from the keyboard buffer so it won't
  15. *  interfere with the calling program following the return.
  16. ***************************************************************/
  17.  
  18. #include <conio.h>
  19. #include <graph.h>
  20.  
  21. void
  22. Message(row, col, text, wait)
  23. short row, col; /* text position */
  24. char *text;     /* text pointer */
  25. short wait;     /* wait flag */
  26.         /* (wait != 0 means wait for a keypress) */
  27. {
  28.     int k;      /* key code */
  29.  
  30.     /*
  31.      * Write the prompt text at the specified location.
  32.      */
  33.     _settextposition(row, col);
  34.     _outtext(text);
  35.  
  36.     /*
  37.      * If the wait flag is set, wait for a key to be pressed,
  38.      * then remove the code from the keyboard buffer.  Handle
  39.      * extended codes by grabbing two bytes if the first is NUL.
  40.      */
  41.     if (wait) {
  42.     while (!kbhit())
  43.         ;
  44.     k = getch();            /* read the character */
  45.     if (k == '\0')
  46.         /* extended code -- get next byte */
  47.         getch();
  48.     }
  49. }
  50.