www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/08/11:22:56

From: apothegm AT no DOT spam DOT softcom DOT net (Nathan Thompson)
Newsgroups: rec.games.programmer,alt.msdos.programmer,comp.os.msdos.djgpp
Subject: Re: Text Mode Program: Help Please..
Date: Mon, 08 Sep 1997 15:21:06 GMT
Reply-To: apothegm AT no DOT spam DOT softcom DOT net
Message-ID: <3414171d.1741671@news.softcom.net>
References: <5uv4i5$t3u AT bgtnsc02 DOT worldnet DOT att DOT net> <3413C028 DOT 159D AT juno DOT com>
MIME-Version: 1.0
NNTP-Posting-Host: 206.107.251.138
Lines: 29
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Mon, 08 Sep 1997 02:06:48 -0700, Chris Thompson
<cdthompson AT juno DOT com> wrote:

>Jay Slanker wrote:
>> 
>> 
>>                 if(kbhit())
>>                           control=getch();
>> 
>This is your problem.  Once kbhit() returns true, it'll keep returning
>true. I'm not sure exactly what resets is, but your best bet is to use
>the _bios_keybrd() routines to check for a character ready and to read
>it. Most compilers I've seen have these functions.
>
>Chris Thompson
>cdthompson AT juno DOT com
I have not found this to be a problem; in both DJGPP and TC++, getch()
seems to remove one character from the keyboard buffer and thereby
turns off kbhit().  There may well be trouble if one /holds down/ a
key, which is why I usually put a loop like this

while (kbhit()) getch();

in critical locations, but a single keypress should be fine.  I
suspect the trouble stems from some other part of the code.

Nathan Thompson
---------------
Remove 'no.spam.' to reply.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019