  
-----------------------------------------------------------------
                            LISTING I
               INKEY FUNCTION FOR USE WITH VAX/VMS

#include descrip

#define  DEV_NAM     "MYTERM"
#define  DEV_NAM_LEN 6

char inkey(short int chan)
{
   char ch;
   unsigned int stat;
     
   stat = sys$qio(0,chan,113,0,0,0,&ch,1,0,0,0,0);
   if ( stat != 1 ) return -1; return ch;
}



main()
{
   struct dsc$descriptor symbol, result;
   short int chan;
   unsigned int stat;
   unsigned short int reslen;
   int table = 2;
   char c, symname[32] = DEV_NAM, resname[128];

   symbol.dsc$w_length  = DEV_NAM_LEN;
   symbol.dsc$b_dtype   = DSC$K_DTYPE_T;
   symbol.dsc$b_class   = DSC$K_CLASS_S;
   symbol.dsc$a_pointer = &symname;

   result.dsc$w_length  = 128;
   result.dsc$b_dtype   = DSC$K_DTYPE_T;
   result.dsc$b_class   = DSC$K_CLASS_S;
   result.dsc$a_pointer = &resname;

   stat = lib$get_symbol(&symbol,&result,&reslen,&table);
   if ( stat != 1 ) exit( stat );
   resname[reslen] = '\0';
   printf("%s",resname);

   result.dsc$w_length  = reslen;

   stat = sys$assign(&result,&chan,0,0);
   if ( stat != 1 )
   {
      printf("error assigning channel\n");
      exit(stat);
   }

   while ((c = inkey(chan)) != -1) printf("%c,%d\n",c,c);

}



