From: system@SendSpamHere.ORG Sent: Tuesday, June 01, 1999 7:48 AM To: Info-VAX@Mvb.Saic.Com Subject: Re: VMS Set Prompt... In article , Matt Miller writes: >I'm looking to set prompt on my interactive session to reflect >the current system time (just HH:MM). Seems easy enough... > >$ TIMEPROMPT=F$EXTRACT(11,5,F$TIME()) >$ SET PROMPT='TIMEPROMPT'---> >21:19---> > >Well that's great. It sets it to 21:19 staticly. Can someone >point me towards a solution that will update dynamically, or >every n minutes? I considered submitting a batch job to do it, >but not sure how I could get that batch job to set the process >for my *interactive* process. This request is similar to the now-FAQed question about setting the prompt to reflect the current working default. There are several "solutions" to this and all have their pros and cons. First, you could set the time via a command procedure. This, how- ever, would require you to use this procedure for all directory and default movement in your process. For example, here's a little bit I have in my LOGIN.COM file and that I have amended to set the time in the prompt: File: LOGIN.COM $! LOGIN.COM.... $ IF "''P1'" .NES "" THEN $ GOTO 'P1' $ $ ... $ ... $ ... $ $ UP :== @SYS$LOGIN:LOGIN.COM UP $ GO :== @SYS$LOGIN:LOGIN.COM GO $ HOME :== @SYS$LOGIN:LOGIN.COM HOME $ DOWN :== @SYS$LOGIN:LOGIN.COM DOWN $ SIDE :== @SYS$LOGIN:LOGIN.COM SIDE $ $ ... $ ... $ ... $ $ EXIT $ $ UP: SET DEF [-] $ SET PROMPT="''F$fao("!5%T-->",0)' $ EXIT $ $ GO: SET DEF 'P2' $ SET PROMPT="''F$fao("!5%T-->",0)' $ EXIT $ $ HOME: SET DEF SYS$LOGIN $ SET PROMPT="''F$fao("!5%T-->",0)' $ EXIT $ $ SIDE: SET DEF 'F$fao("[-.!AS]",(F$element(0,";",P2)-".DIR")) $ SET PROMPT="''F$fao("!5%T-->",0)' $ EXIT $ $ DOWN: SET DEF 'F$fao("[.!AS]",(F$element(0,";",P2)-".DIR")) $ SET PROMPT="''F$fao("!5%T-->",0)' $ EXIT You could, of course, modify the above and massage it to fit your needs. The problem here is that a simple $ SET DEFAULT will not set your prompt to reflect the time. In addition, the prompt will only reflect the time of the last use of any of the "short-cut commands" above. Typically, the "SET PROMPT to directory path" requires a kernel- mode hack to intercept the SYS$SETDDIR service and then, update the P1 space cell which maintains the DCL prompt string. I'd prefer to implement it this way if I were doing it -- and I have. In fact, I have a product (beta testers???) which does this and allows the user to specify writing the current default to the DCL PROMPT, the status line (25th line) or the title bar of a DECterm. It's also user ex- tensible allowing the user to write their own "stub" to be invoked when the default is changed. (Sorry, shameless plug but it is some- what pertainent to the question.) The problem with this approach is that it too will only update the prompt when the default is changed (or SHOW DEFAULT which also uses SYS$SETDDIR) and thus, only the time of the last SET DEFAULT will be displayed. Works great if displaying the current default but not so if you desire the current time. There was a "hack" floating about at one time which copied code into (I would hope) P1 space and then, queued a repeating timer AST to set the prompt by writing to the cell maintaining the DCL prompt. This has the added advantage of having the time updated each time the DCL prompt is written to the display such as when you would simply type a carriage return. Unfortunately, the displayed time will remain at the time of the last prompt activity. This was VAX only too although I could easily hack up a similar Alpha ditty. With a little more kernel mode hacker wizardry, the prompt could be programmed to be updated as long as there were no current input being entered at the prompt. This means hacking into the RMS information stored in P1 for the DCL prompt display/terminal input. Yeah, I've mucked about with this too but it it all worth it??? The bottom line... if you want to know the current time, buy a watch! BTW, IF your terminal has a 25th host writeable status line, you could write a continually updated clock to that line... I'd wager it would be a whole world better than using the DCL prompt. -- VAXman- OpenVMS APE certification number: AAA-0001 VAXman@TMESIS.COM "Now what else is the whole life of mortals but a sort of comedy, in which the various actors, disguised by various costumes and masks, walk on and play each one his part, until the manager waves them off the stage?" -- Erasmus