1. Help needed please

Hi there fellow Eu4ians

I've got a bit of a problem, and I can't seem to find the answer in RefMan.
How do you flush the kbd buffer (DOS)?
I've tried flush(0), but it comes back with an error, and I've tried close(0),
but I can't seem to open it again.
Or, failing that, is there a way of closing off the kbd, and then re-opening
after?
It seems a simple thing to want, but it's driving me up the wall at the minute.

TIA

Sid


--


Sid Sidebottom - Senior Operations Technician
STMicroelectronics

Tel: +44 (0)131 336 6116
Fax: +44 (0)131 336 6001
Email: sid.sidebottom at st.com
WWW: http://www.vvl.co.uk
www.st.com

new topic     » topic index » view message » categorize

2. Re: Help needed please

Sid Sidebottom wrote:

> How do you flush the kbd buffer (DOS)?

Here are some snippets of code from keys.e by D.Cuny:

Colin Taylor

-----
constant
    KEY_BUFFER = 1054,   -- keyboard buffer; circular queue
    FIRST_INDEX = 1050,  -- index to first key in buffer
    LAST_INDEX = 1052    -- index to last key in buffer

-- buffer is empty is indexes point to each other
if peek( FIRST_INDEX ) = peek( LAST_INDEX ) then
-- nothing in the buffer
end if

SCAN_CODE = peek( KEY_BUFFER + peek( FIRST_INDEX ) - 29 )
KEY_CODE = peek( KEY_BUFFER + peek( FIRST_INDEX ) - 30 )

-- clear the buffer
poke( FIRST_INDEX, peek( LAST_INDEX ) )
-----

new topic     » goto parent     » topic index » view message » categorize

3. Re: Help needed please

Colin's answer was pretty good, but if you're just trying to get rid of =
extra CRLF's, etc., perhaps this line could work:

while getc(0)!=3D-1 do end while

As long as getc() returns a character, the buffer isn't flushed.  When it =
returns -1, that's the end of it all.

HTH,
Michael J. Sabal

>>> Sid.Sidebottom at ST.COM 07/20/00 04:01AM >>>
I've got a bit of a problem, and I can't seem to find the answer in =
RefMan.
How do you flush the kbd buffer (DOS)?

new topic     » goto parent     » topic index » view message » categorize

4. Re: Help needed please

Colin Taylor wrote:

> Here are some snippets of code from keys.e by D.Cuny:
> ...
> -- buffer is empty is indexes point to each other

Oops. That should have been "...IF indexes point to each other"

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

5. Re: Help needed please

On Thu, 20 Jul 2000 08:48:12 -0400, Mike Sabal <MikeS at NOTATIONS.COM> wrote:

>Colin's answer was pretty good, but if you're just trying to get rid of
extra CRLF's, etc., perhaps this line could work:
>
>while getc(0)!=-1 do end while
>
>As long as getc() returns a character, the buffer isn't flushed.  When it
returns -1, that's the end of it all.
>
>HTH,
>Michael J. Sabal

Sorry for the delay in reply, and thanks to Colin and Mike for the response.
I lazily opted for Mike's simpler solution (sorry Colin), but found that the
line needed to be changed to
while get_key() !=-1, presumably getc doesn't return an end of file marker
for the kbd.
Anyway, all sorted now, thanks again

Sid

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu