From:	CSBVAX::MRGATE!COSC1Q0@uhvax1.uh.edu@SMTP 16-MAY-1988 15:51
To:	ARISIA::EVERHART
Subj:	Does anybody really know what time it is?


Received: from uhvax1.uh.edu by KL.SRI.COM with TCP; Thu 12 May 88 08:05:06-PDT
Date: Thu, 12 May 88 10:02 CST
From: "Lee K. Gleason, Control-G Consultants" <COSC1Q0@uhvax1.uh.edu>
Subject: Does anybody really know what time it is?
To: info-vax@kl.sri.com
X-VMS-To: IN%"info-vax@kl.sri.com",COSC1Q0

  This is the ultimate "put the time in your DCL prompt" program. It 
turns your VAX into the most expensive wristwatch in the world.

  It has two drawbacks...

1. It requires CMEXEC privilege to run (no problem for any of us, 
right?)

2. As it is scheduled by an AST once a second, you probably don't want 
EVERYONE at your site running it.


  But, seriously, folks, what it is is an example of how to put a 
timer based daemon to work in your process, without the cumbersome 
annoyance of a subprocess.

  To use...cut the file CLOCK.MAR out of here...then

$ MAC CLOCK
$ LINK CLOCK,SYS$SYSTEM:SYS.STB/SEL,DCLDEF.STB/SEL
$ RUN CLOCK
16:42:13>

The next prompt should be the time, with an arrow following. All 
following prompts will continue to have the updated time in them.


  Well, 'bout time for a disclaimer here. This routine runs in EXEC 
mode. If it causes problem on your system ... don't run it. I have 
used it on VAXen of all sizes and versions, with no problems...but, 
who knows?
  And of course, along with every other EXEC or KERNEL mode program in 
the world, it has little chance of running on a Version 5 VMS system, 
without a little work.


Lee K. Gleason
Control-G Consultants
2416 Branard #D
Houston TX 77098

Phone 713/528-1859

COSC1Q0@UHVAX1.UH.EDU (but, since I didn't get into summer school,
			I'll lose access to the net on MAY 10).

"One step done, and another begun, and I wonder, how many miles?"

*******************************************************************

	.entry	clock,^m<>

	$cmexec_s -
		routin = do_clock	;call our loader, in exec mode

	$exit_s	r0	;get out of the door, light out and look all around

	.entry	do_clock,^m<>

	movl	#rolexlen,r1		;how much we need?
	jsb	g^exe$alop1proc		;try to get it
	movl	r2,r6			;save address of block allocated
	movc3	#rolexlen,rolexcode,(r2)	;copy our code

	$setimr_s	daytim = rolextime,-	;set the timer for next time
			astadr = (r6)		;at the load address
	ret


	.entry	rolexcode,^m<r2>

	tlen = -4	;length of time conversion stack offset
	tbuf = -12	;descriptor for ASCII string returned by $ASCTIM here

	subl	#12,sp	;room for space on the stack

	$setimr_s	daytim = rolextime,-	;set alarm for next update
			astadr = rolexcode	;use relative address

	moval	@#ctl$ag_clidata,r2	;addr of CLI data area here
	movl	ppd$l_prc(r2),r2	;addr of another area
	moval	prc_g_prompt(r2),r2	;addr of the prompt buffer

;+
;  the prompt buffer is arranged thusly...
;  1st byte The byte count of all following bytes
;  2nd byte a Carriage return
;  3rd byte a Line Feed
;  4th byte The DCL line continuation prompt character. It is
;		preficxes your normal prompt on the lines following
;		a hyphen-continued line.
; 5th through N bytes
;	the actual prompt string. Note well, that byte 5 is where
;	prc_g_prompt points - the bytes above precede it.
;-

	movl	r2,tbuf+4(fp)	;address of the prompt buffer
	movl	#8,tbuf(fp)	;max len

	$asctim_s	timlen = tlen(fp),-	;convert time to asc
			timbuf = tbuf(fp),-	;use desc on stack
			timadr = @#exe$gq_systime,-	;use system time
			cvtflg = #1		;leave the date off, ok?

	clrl	r0			;make sure it's empty
	addw3	#3+1,tlen(fp),r0	;make length come out ok
	movb	r0,-4(r2)		;store new prompt length
	movb	#^A/>/,-4(r2)[r0]				
	ret			;get back, JoJo

rolextime:
	.long	^XFF67697F	;this is a second, relative time
	.long	^XFFFFFFFF	;you can change, to make long or short

rolexlen=.-rolexcode		;This is The End, my only friend, The End

	.end	clock
