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