#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    32
    Rep Power
    12

    Is there a way to read two-byte character codes with a single function...


    Is there a way to read extended keys (e.g. F Keys and Arrow key) through a single function. I don't want to use "getch()" or same kind of function twice...

    THe function should also be able to read in a single-byte character automatically if the user doen't press an extended key...
    posted by: justujoo

    Error 13: BRAIN.SYS not responding, process terminted...!
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,641
    Rep Power
    4247
    Something like this maybe?
    Code:
    #define NORMAL_KEY 1
    #define SPECIAL_KEY 2
    
    int mygetch(int *byte1, int *byte2) {
        int retval = NORMAL_KEY;
        *byte1 = getch();
        if (*byte1 == 0)  {
            /* This is a F or arrow key*/
            *byte2 = getch(); 
            retval = SPECIAL_KEY
        }
        return retval;
    }

IMN logo majestic logo threadwatch logo seochat tools logo