VAX-C immediate char reading

Eychaner, Glenn C. gceych at juliet.caltech.edu
Sat Dec 15 06:43:43 AEST 1990


In article <1990Dec14.191104.7874 at athena.mit.edu>, seaotter at athena.mit.edu writes...
> 
>Another question I'm sure has been posted before...
> 
>Is there a way under VMS 5.x using Curses (yes, NOT smg$stuff)
>to write some function next_avail_char() such that I could write
>a code fragment like
> 
>	for(;;) {
>	  if ((c = next_avail_char()) != '\0') {
>	    dostuff();
>	  } else {
>	    update_something();
>	  }
>	}
> 
>In other words I need to know if there is input waiting and if so,
>what it is.
> 
>Post or email c/o seaotter at athena.mit.edu or mzraly at ldbvax.dnet.lotus.com
>The MIT address is probably better, though.
> 
> 
>Thanks,
> Mike
> 
> 
> 
>--
> 
>| Mike Zraly                     | You should never wear your best trousers |
>|                                | when you go out to fight for freedom and |
>| via: seaotter at athena.mit.edu   | liberty. -- Henrick Ibson                |

I wanted to post this to see what OTHER people have gotten...my solution is
really weird.
I found that if I ABSOLUTELY COVERED stdscr with windows, performed a
nocrmode() and a noecho(), and then tried a getch() or getstr() (I believe
those are the calls), I get the type of behaviour you described.  However, I
found it difficult to actually enter a key, and it ate up CPU like a demon.
I don't recommend this at all.  I eventually gave up on it.
BTW, according to my CURSES manual, the functions raw() and noraw() are
supposed to return after something like 5 seconds OR a key is pressed.
I ended up calling SMG$CREATE_VIRTUAL_KEYBOARD and SMG$READ_KEYSTROKE.  These
also allow you to read the function keys and arrows and numeric keypad in
applications mode.  In fact, some of my programs are rapidly becoming
curses/smg$ hybrids...seems safe enough as long as you're careful, i.e. use
only one of them for terminal screen output (I hate string descriptors and
passing lots of things by reference).

Glenn Eychaner   |Eychaner at SunCub.Caltech.edu |Remember: It is easier to ride a
40386 N Shore Ln |gceych at iago.caltech.edu     |camel through the eye of a needle
Big Bear City, CA| Big Bear Solar Observatory |than to drive a Buick through the
            92314| !*** G O  N I N E R S ***! |hole in a doughnut.



More information about the Comp.lang.c mailing list