BITNET@UTHSCSA.BITNET.UUCP (03/01/87)
Subject: Direct input in C on vax > I cannot find a way to directly read input from the keyboard, character >by character. The routines I know of in C all require the user to hit <return> >at the end of the line to signal to the computer that input is done. If there >is some way around this, I would greatly appreciate it. In this particular test program I was trying to read a delete character. It should at least get you started. In this test program I didn't deassign the channel. I don't have a system services manual here at home, and I don't remember the exact call. I think it is $deassign(channel), but I can't swear to it. Mark Moore Moore@UTHSCSA The University of Texas Health Science Center San Antonio, Texas 78284 ------------------------------------------------------------------------------- # include <iodef.h> # include <descrip.h> main() { int i; /* used to index loop */ char keypress; /* store character returned from termread */ short int channel; /* get term chan from $assign */ termchan(&channel); i = 20; do { termread(&channel,&keypress); printf("keypress = %c\n",keypress); if (keypress == 27 ) { printf("that was an escape\n"); } if (keypress == 127 ) { printf("that was most definitely a delete\n"); } i--; } while (i); } termchan(channel) short int *channel; /* must be a word. It won't work if */ /* you make it a long word. */ { int stat; /* store return status from sys calls */ char term[20] = " "; $DESCRIPTOR(dst,term); ctermid(term); stat = sys$assign(&dst,channel, 0, 0); } termread(channel,buffer) short int *channel; char *buffer; /* buffer for characters */ { int length; /* length of buffer */ int stat; /* store return status form sys calls */ length=1; stat = sys$qiow(0, /* event flag */ *channel, /* channel */ IO$_READVBLK+IO$M_NOECHO+IO$M_NOFILTR, /* function */ 0, /* iosb */ 0, /* astadr */ 0, /* astprm */ buffer, /* p1 */ length, /* p2 */ 0, /* p3 */ 0, /* p4 */ 0, /* p5 */ 0); /* p6 */ }