Newsgroups: comp.sys.transputer
From: adc@threel.co.uk (Alan Culloch)
Subject: Re: Problem with 3L C
Organization: 3L Ltd
Date: Fri, 22 Jul 1994 11:38:46 +0000
Message-ID: <CtCB0M.32q@threel.co.uk>

In article <1994Jul21.223629.29240@percy.robots.ox.ac.uk>,
pm@robots.ox.ac.uk (Philip McLauchlan) writes:

[...Using 3L Parallel C for the C40...]
>What we need is a function to poll the keyboard for input, returning
>a special value if no input is present.

The following code should do what you need:

   int get_a_key(void)
   {
      int k, result;
      _put_int(29);                /* service code   */
      _get_int(&k);                /* read key value */
      _get_int(&result);
      if (result != 0) return -1;  /* if operation failed   */
      return k;                    /* else returm key value */
   }

This will return a character code, or -1 if no keystroke is pending.
_put_int() and _get_int() are built-in library functions which talk
to the host server.

Alan Culloch,
3L Ltd.,
adc@threeL.co.uk




