Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!ginosko!uunet!usna!baldwin
From: baldwin@usna.MIL (J.D. Baldwin)
Newsgroups: comp.lang.pascal
Subject: Re: Clearing the keyboard buffer
Message-ID: <246@usna.MIL>
Date: 3 Oct 89 01:02:54 GMT
References: <1169@krafla.rhi.hi.is> <708@thor.wright.EDU>
Reply-To: baldwin@cad.usna.mil (J.D. Baldwin)
Organization: Canoe U.
Lines: 25

In article <708@thor.wright.EDU> bkottman@wright.EDU (Brett Kottmann) writes:
>in article <1169@krafla.rhi.hi.is>, karlth@rhi.hi.is (Karl Thoroddsen) says:
>>[asks how to clear the keyboard input buffer in Turbo 4.0]
>
>	readln;
>	or
>	readln(garbage_variable);
>
>should do it.  Although I'm shure there is a more elegant solution.

Well, I'm a Turbo 5.0 man myself (never used 4.0), but I can't imagine that
this would work.  If there are characters in the input buffer *after* the
last , or if there has been no .  Also, Brett's solution has the
(possibly extremely serious) defect that it will pause and ask for an
unintended input if there is nothing in the input buffer.

My solution:

        while KeyPressed do ReadKey;
--
From the catapult of:               |+| "If anyone disagrees with anything I
   _, J. D. Baldwin, Comp Sci Dept  |+| say, I am quite prepared not only to
 __||____..}->     US Naval Academy |+| retract it, but also to deny under
 \      / baldwin@cad.usna.navy.mil |+| oath that I ever said it." --T. Lehrer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~