Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!apple!dlyons
From: dlyons@Apple.COM (David Lyons)
Newsgroups: comp.sys.apple
Subject: Re: IIGS filter procedure for dialog box
Message-ID: <35138@apple.Apple.COM>
Date: 30 Sep 89 00:47:57 GMT
References: <12232@boulder.Colorado.EDU>
Organization: Apple Computer Inc, Cupertino, CA
Lines: 37

In article <12232@boulder.Colorado.EDU> hartkopf@tramp.Colorado.EDU (Jeff Hartkopf) writes:
>[...] if the event's what field is keyDownEvt,
>is the message field the character pressed?

Yes, the low-order byte is (Toolbox Ref vol 1, page 7-8).

Your approach looks good.  Change
>    #define c evtptr->message

to
     #define c (evtptr->message)&0xFF

(Or, better yet, try:

  char c = (evtptr->message)&0xFF;

That way you'll avoid having the compiler generate the code to check
that field 7 times.

>    if (evtptr->what == keyDownEvt)
>        if (c != RETURN && (c < '0' || (c > '9' && c < 'A') ||
>                    (c > 'F' && c< 'a') || c > 'f'))  /* invalid */
>            return (TRUE);  /* just ignore them */

My, that's pretty scary to read.  Double check that you don't have
any precedence problems (and remind me to get a C reference for my
cube :-) .  [I can never remember where "!=" fits into the precedence
hierarchy...usually I use lots of parentheses & don't worry about it.]
-- 

 --Dave Lyons, Apple Computer, Inc.          |   DAL Systems
   AppleLink--Apple Edition: DAVE.LYONS      |   P.O. Box 875
   America Online: Dave Lyons                |   Cupertino, CA 95015-0875
   GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
   Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons

   My opinions are my own, not Apple's.