#include <stdio.h>
#include <string.h>
#include <descrip.h>

int smg$create_virtual_keyboard();
int smg$read_string();

void setbit(char *s,int v)
{
   s[v/8]|=(1<<(v%8));
   return;
}

main()
{
   long kbid,i;
   char res[512],pmt[80],term[32];
   struct dsc$descriptor resdes,pmtdes,termdes;
   resdes.dsc$w_length=sizeof(res);
   resdes.dsc$b_dtype=DSC$K_DTYPE_T;
   resdes.dsc$b_class=DSC$K_CLASS_S;
   resdes.dsc$a_pointer=res;
   strcpy(pmt,"Try enter two A's and terminate with return> ");
   pmtdes.dsc$w_length=strlen(pmt);
   pmtdes.dsc$b_dtype=DSC$K_DTYPE_T;
   pmtdes.dsc$b_class=DSC$K_CLASS_S;
   pmtdes.dsc$a_pointer=pmt;
   termdes.dsc$w_length=sizeof(term);
   termdes.dsc$b_dtype=0;
   termdes.dsc$b_class=0;
   termdes.dsc$a_pointer=term;
   smg$create_virtual_keyboard(&kbid);
   smg$read_string(&kbid,&resdes,&pmtdes,0,0,0,0);
   printf("OK !\n");
   for(i=0;i<sizeof(term);i++) term[i]=0;
   setbit(term,'A');
   smg$read_string(&kbid,&resdes,&pmtdes,0,0,0,&termdes);
   printf("\rOK !\n");
   for(i=0;i<sizeof(term);i++) term[i]=0;
   setbit(term,13);
   smg$read_string(&kbid,&resdes,&pmtdes,0,0,0,&termdes);
   printf("OK !\n");
   for(i=0;i<sizeof(term);i++) term[i]=0;
   setbit(term,13);
   setbit(term,'A');
   smg$read_string(&kbid,&resdes,&pmtdes,0,0,0,&termdes);
   printf("\rOK !\n");
}
