delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/21/18:01:39

From: Mike McLean <libolt AT primenet DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro: reading input and comparing with switch
Date: 21 Nov 1997 15:08:01 -0700
Organization: Primenet Services for the Internet
Lines: 24
Message-ID: <347606B0.B6FBA767@primenet.com>
References: <3474CB66 DOT BBF414A5 AT primenet DOT com> <6534h4$qu0$2 AT news DOT ox DOT ac DOT uk>
MIME-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

George Foot wrote:
> 
> On 20 Nov 1997 16:43:00 -0700 in comp.os.msdos.djgpp Mike McLean <libolt AT primenet DOT com> wrote:
> 
> : I have functions that read in input using allegro's readkey command, and
> : I have that character or letter checked by a switch statement.  The
> : Problem is sometimes it takes 2 or 3 times hitting the key to get it to
> : read it.  I'm stuck here.  Please help me out.
> 
> You're calling readkey twice!  When you write:
> 
> :   readkey();
> :   switch(readkey() & 0xff)
> ...
> 
> it calls readkey(), which waits for a key to be pressed, and discards
> the value returned.  Then it calls readkey() again, which waits for
> another keypress, and uses that value to index the switch statement.
> You need to get rid of the first readkey, perhaps.
> 
> --
> george DOT foot AT merton DOT oxford DOT ac DOT uk

I figured this out late last night :)  Thanks for the help.

- Raw text -


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