Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!ginosko!uunet!mcsun!sunic!tut!ra!chyde!ts
From: ts@chyde.uwasa.fi (Timo Salmi LASK)
Newsgroups: comp.lang.pascal
Subject: Re: Clearing the keyboard buffer
Keywords: intr21
Message-ID: <823@chyde.uwasa.fi>
Date: 3 Oct 89 11:03:12 GMT
References: <1169@krafla.rhi.hi.is> <708@thor.wright.EDU>
Reply-To: ts@chyde.uwasa.fi (Timo Salmi LASK)
Organization: U of Vaasa, Finland
Lines: 26

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:
>> While writing in TURBO 4.0 I've constantly encountered the problem
>> of not being able to flush(clear) the keyboard buffer.
>
>	readln;
>	or
>	readln(garbage_variable);
>should do it.  Although I'm shure there is a more elegant solution.

I am afraid that this is not a working solution at all for at least
two reasons.  The flushing in it only takes place when the enter key
is pressed, and it does not work for the special keys such as F1 or
esc.  The other solution that has been suggested (while KeyPressed
do ch := ReadKey;) is better, but it is also problematic if the
ensuing input involves the special keys with ReadKeys.  And if the
input and output get out of phase, it is not guaranteed to have a
desired affect.  What one has to do is to resort to system services. 
Interrupt 21Hex service 0CHex can be used for the flushing.  Norton
& Wilton is a good source for further details.  (If you disagree,
ok, Brett, but would you please not make it a personal attact.)

...................................................................
Prof. Timo Salmi                                (Site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun