From: CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 15-MAR-1991 04:25:24.96 To: ARISIA::EVERHART CC: Subj: RE: kbhit for VMS From: RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2 To: Everhart@Arisia@MRGATE Received: by crdgw1.ge.com (5.57/GE 1.91) id AA12280; Fri, 15 Mar 91 04:09:35 EST Received: From PUCC.PRINCETON.EDU by CRVAX.SRI.COM with TCP; Thu, 14 MAR 91 11:23:32 PST Received: from IRLEARN.UCD.IE by pucc.PRINCETON.EDU (IBM VM SMTP R1.2.2MX) with BSMTP id 3804; Thu, 14 Mar 91 14:24:18 EST Received: from ccvax.ucd.ie by IRLEARN.UCD.IE (Mailer R2.07) with BSMTP id 7324; Thu, 14 Mar 91 19:05:41 GMT Received: from saturn.eolas.ie by ccvax.ucd.ie; Thu, 14 Mar 91 18:55 WET Date: Thu, 14 Mar 91 18:59 GMT From: Louis Dunne Subject: RE: kbhit for VMS To: INFO-VAX@sri.com Message-Id: X-Envelope-To: INFO-VAX@sri.com X-Vms-To: IN%"INFO-VAX@sri.com" In reply to ... > > > Hi netters! > > I've got a question, (last time I asked about SMG), I've built a > program using SMG$CREATE_VIRTUAL_KEYBOARD and SMG$READ_COMPOSED_LINE > to use VMS's recall buffer. I got what I wanted from DEC (Colorado) > and I revised and tested and finally got it to work. > Now the question I have is about a C routine available in Micro-Soft) C > called kbhit which allows you to interupt processing by typing any > key on the keyboard, I need this on the VAX, I can't seem to get > SMG$READ_KEYSTROKE > to work under these conditions. For example I'm reading in records > from a file, processing them, taking data from them and then I want to > stop - only not every time - in the middle of that to look at my screen, > I hit any key and the processing stops, I look at my screen, press any > key when I'm done looking and the read resumes where I left off. If I > don't press any key it reads all through the file. > > example: > > while (!(kbhit())) { > blah > blah > blah > } > > or > while((fgets(str,80,infile)) != NULL) /* reading a line from infile to s tr*/ > { > if(kbhit()) > { > getchar(); > break; > } > line_num++; /* increment line counter */ > > > I hope I am making sense to all of you, thanks again for your > help with SMG and I appreciate you getting back to me. > > > Dwain A. Erhart > NOSC PGC San Diego > > /********************************************************************/ > I said WHAT! No... what I meant was.... > /********************************************************************/ > > It seems to me that what you want to do, is to interrupt processing at any time when a key is hit, yes ? SMG allows you to do this easily; SMG$ENABLE_UNSOLICITED_INPUT is just the trick. Do the following :- Set up an AST (asynchronous system trap), i.e. just a routine in your C program, and send the address of this to the SMG routine (it also takes the pasteboard-id, and [optionally] an argument). Prototype your function as (e.g.) :- int ast (); Your function could be :- int ast (struct SMG$R_OUT_OF_BAND_TABLE *table) { printf ("key hit=%d", table->SSMG$R_CHAR_OVERLAY.SMG$B_CHAR); } You can get at your argument (such as a structure for your info.) using table->SMG$L_USER_ARG. The format/size of the character hit and arg. can vary (as far as I can remember), so you had best consult the manual for the SMG$ routines. Oh, lastly use the SMG$ENABLE_UNSOLICITED_INPUT routine to have your function invoked, at every keypress :- ret_code = SMG$ENABLE_UNSOLICITED_INPUT (pboard, ast, &some_struct); (Set this up in some initialisation code, or just around the parts where you need to detect the keypress.) To zap this 'trap' at any point use :- ret_code = SMG$DISABLE_UNSOLICITED_INPUT (pboard); Let me know if this is what you are looking for, I may have some code somewhere that uses this (but exactly where is uncertain right now). Louis Dunne.