From: SMTP%"eychaner@SUNCUB.BBSO.CALTECH.EDU" 7-FEB-1994 10:25:57.35 To: EVERHART CC: Subj: Re: Help pls: ASTs and SMG X-Newsgroups: comp.os.vms Subject: Re: Help pls: ASTs and SMG Message-Id: <2ivfha$20r@gap.cco.caltech.edu> From: eychaner@SUNCUB.BBSO.CALTECH.EDU ("Channel Energy") Date: 5 Feb 1994 06:49:14 GMT Reply-To: eychaner@SUNCUB.BBSO.CALTECH.EDU Organization: Big Bear Solar Observatory, Caltech Nntp-Posting-Host: suncub.bbso.caltech.edu Lines: 80 To: Info-VAX@CRVAX.SRI.COM X-Gateway-Source-Info: USENET palmer@qut.edu.au writes: >Greetings all, > I have a small problem with SMG. I wish to put a clock in the corner >of the screen of my application. An interesting question, and one I have been thinking about recently myself. I'd appreciate any hints. Here are a few of my thoughts on the subject (I apologize for quoting so much text): >Currently I am just running an ast routine via $setimr. I look up which >display has the cursor - update the clock and restore the cursor position >to the 'known' position in that display and that works BUT. >The SMG manual makes clear reference to 'not re-entrant' and 'not AST >re-entrant'. I am concerned that depending what is currently being done in >non AST code could get screwed up by the clock AST routine. >The manual is not clear as to what one should do. Of course I can disable >ASTs using SETAST - a big hammer. > >The mechanisms I am considering at the moment are - >1) Disable AST's while any non-ast code is performing SMG functions - > looks one hell of a problem for read functions! The solution for read functions is as follows. Inside your AST routine, issue a SMG$CANCEL_INPUT. Then make your input routines requeue when a return code of $_CANCEL or $_ABORT, like so: (C code-fragment example for $READ_STRING, init_d and ret_d are string descriptors. Note: this routine uses a separate single-line window for input, thus the $HOME_CURSOR rather than a $SET_CURSOR_ABS.) /* Loop each time input is cancelled by AST */ do { /* Copy last return string to initial string */ STR$COPY_DX (&init_d, &ret_d); SMG$HOME_CURSOR (&disp_id, 0); status = SMG$READ_STRING (&kb_id, &ret_d, &prompt_d, &maxlen, &mask, 0, 0, &length, 0, &disp_id, &init_d, 0, 0, 0); } while (status == SS$_ABORT || status == SS$_CANCEL); This works for broadcast trapping as well, eliminating a lot of hassle with finding the cursor and repositioning it. I find that using this, I don't have to bother with finding the cursor and putting it back, at least in broadcast-trapping routines. Thanks to whoever pointed this out to me in the long-distant past. >2) Use the Batch update feature and disable AST's while the output actually > occurs Personally, I wouldn't worry TOO much about the output, especially if you put the cursor back where you found it each time. (Like I said, I never do in my broadcast trapping routines, and it seems to work.) How can you be sure of disabling ASTs while the output occurs? Disable ASTs, end batching, and re-enable ASTs? Is this guaranteed? >3) Use a broadcast message to the terminal that has a special start and look > for that in the AST routine that displays broadcast messages. If it > is a time message then update the clock virtual display. This is quite clever, but also quite slow, I suspect. You might want to just have a special broadcast message that tells the broadcast trap to update the clock, rather than actually sending the time in a message. >I can't be the only one to ponder this problem. Can someone please indicate >how it can be done? I really don't know, other than $CANCEL_INPUT for reads, and possibly putting the cursor back. You COULD use $CREATE_SUBPROCESS to associate a subprocess with a 1-line time window, and then have your AST call $EXECUTE_COMMAND every time the timer expires to execute a program that prints the time, which would then appear in the window. But that sounds REALLY dumb, and eats system resources besides. Anyone else want to give it a shot? -G. Glenn Eychaner, C Programmer & VMS Manager, Big Bear Solar Obs., Caltech eychaner@suncub.bbso.caltech.edu (909)866-5791 40386 North Shore Lane SUNCUB::EYCHANER, 5554::EYCHANER (818)395-4014 Big Bear City, CA 92314