Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!psuvax1!psuvm!tbc101
From: TBC101@PSUVM.BITNET (Thomas B. Collins, Jr.)
Newsgroups: comp.lang.pascal
Subject: Re: Clearing the keyboard buffer
Message-ID: <89276.021637TBC101@PSUVM.BITNET>
Date: 3 Oct 89 06:16:37 GMT
References: <1169@krafla.rhi.hi.is> <48.filbo@gorn.santa-cruz.ca.us>
Organization: Penn State University
Lines: 21

In article <48.filbo@gorn.santa-cruz.ca.us>, filbo@gorn.santa-cruz.ca.us (Bela
Lubkin) says:
>
>In article <1169@krafla.rhi.hi.is>, Karl Thoroddsen writes:
>> While writing in TURBO 4.0 I've constantly encountered the problem
>> of not being able to flush(clear) the keyboard buffer.
>
>Var Crud: Char;
>..
>  While KeyPressed Do Crud:=ReadKey;  { Flush keyboard buffer }
>
   If Crud = #0 then Crud := ReadKey;  { Use in case of extended key code}

If the last character in the buffer was "extended" (Alt-something,
etc.), Keypressed will be false, but there will still be a value in
ReadKey to be read.  If you forget to read this, it can cause trouble
later on...

-------
Tom "Shark" Collins       Since ICS is comprised of 2 people, my views
tbc101@psuvm.psu.edu      are the opinion of at least 50% of the company.