home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / msdos / programm / 8512 < prev    next >
Encoding:
Text File  |  1992-08-13  |  1.7 KB  |  45 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!ncoast!brown
  3. From: brown@NCoast.ORG (Stan Brown)
  4. Subject: Re: Summary: How to flush keyboard buffer
  5. Organization: Oak Road Systems, Cleveland Ohio USA
  6. Date: Thu, 13 Aug 1992 10:03:40 GMT
  7. Message-ID: <1992Aug13.100340.26026@NCoast.ORG>
  8. Keywords: Keyboard buffer, DOS
  9. References: <3748@keele.keele.ac.uk>
  10. Lines: 33
  11.  
  12. In article <3748@keele.keele.ac.uk> coa44@seq1.keele.ac.uk (Mark Scase) writes:
  13. >
  14. >Many thanks to all the people who replied to my recent question I
  15. >posted in comp.os.msdos.programmer asking how to flush the keyboard
  16. >buffer in Borland C under DOS.
  17. >
  18. >I received 3 different ways of flushing the keyboard buffer which
  19. >worked.  They are:
  20. >
  21. >while (kbhit()) getch();
  22. >while (bioskey(1)) bioskey(0);
  23.  
  24. These two are very likely the same thing.  If they are implemented in
  25. the obvious way, however, they will miss keystrokes like F12.
  26.  
  27. >while (bioskey(1)) if (!getch()) getch();
  28.  
  29. This is a roundabout version of the others.  The difference is that if
  30. an extended key (function or cursor key) is waiting in the buffer, it
  31. will be flushed in one pass through the loop rather than two.  But
  32. there's no advantage to that feature, and it makes the source program
  33. longer.
  34.  
  35. I can understand why keyboard input is so confusing.  At a quick count I
  36. see eight DOS and BIOS functions to take keystrokes from the buffer or
  37. check the buffer for waiting keystrokes, or both.  No wonder people get
  38. confused!
  39.  
  40. -- 
  41. Stan Brown, Oak Road Systems                      brown@Ncoast.ORG
  42.  
  43. "Ingrate, n.  One who receives a benefit from another, or is otherwise
  44. an object of charity."                          --Ambrose Bierce
  45.