From:	CSBVAX::MRGATE!@KL.SRI.Com:info-vax-request@kl.sri.com@SMTP 21-AUG-1987 23:39
To:	EVERHART
Subj:	Re: Calculating Elapsed Time From DCL.

Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Fri 21 Aug 87 12:48:41-PDT
Received: by ucbvax.Berkeley.EDU (5.58/1.27)
	id AA10758; Fri, 21 Aug 87 12:45:15 PDT
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 21 Aug 87 16:33:21 GMT
From: necntc!rayssd!d2b@husc6.harvard.edu  (Donald A. Borsay)
Organization: Raytheon Company, Portsmouth RI
Subject: Re: Calculating Elapsed Time From DCL.
Message-Id: <1471@rayssd.RAY.COM>
References: <870805075119.03q@VLSI.JPL.NASA.GOV>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

In article <870805075119.03q@VLSI.JPL.NASA.GOV> 
xrjjm%scint.span@VLSI.JPL.NASA.GOV (John McMahon writes:
>
>Lately I have been playing with the various F$xTIME commands that DCL
>offers and I have noticed a couple of things that either are shortcomings,
>or more likely things I have missed somewhere.
....
>My second time question is, how does one calculate a delta time between two
>dates (also in DCL).  I am primarily concerned with the number of days
>between two dates, but knowing how to figure it out to the second would be
>nice.

Ok, John and other Netlanders, here's a program I wipped up to assist me in
some benchmark DCL procedures I did a while back.  Simply cut at the
dotted line and replace all $$ with a tab (I here tabs cause some mailers
pain).  I know this works with Fortran 4.4 and VMS 4.4.  Enjoy!!
----
Don    |Raytheon Company, Submarine Signal Division, Portsmouth, RI
Borsay |ARPAnet: d2b%rayssd.RAY.COM@a.cs.uiuc.edu
       |UUCPmail: {allegra, decvax!brunix, linus!raybed2}!rayssd!d2b
----------- CUT HERE ---------- CUT HERE ------- CUT HERE --------------

$$program delta	!delta_return = p1 - p2
$$implicit none
c*************************************************************************
c PROGRAM:$$DELTA
c WRITTEN BY:$$Don Borsay
c 
c DELTA takes p1 and p2 are absolute ascii times, and creates the DCL
c global symbol delta_return as the delta ascii time difference of
c P1 - P2
c*************************************************************************

$$integer	sys$bintim,	!Converts ascii time to binary
     x$$	sys$asctim,	!Converts binary time to ascii
     x$$	lib$subx,	!Subtracts binary of arbitrary length
     x$$	lib$get_foreign,!Get parameters from foreign command line
     x$$	index,		!Position of substring (p2) in string (p1)
     x$$	lib$set_symbol	!Generate DCL symbol for return value

$$integer	time_a(2), 	!Binary form of p1
     x$$	time_b(2), 	!Binary form of p2
     x$$	delta_return(2),!Binary form of subtracted result
     x$$	string_length*2 !Length of string_delta_return
     $$logical	status*4	!Status code returned from system routines
$$character string_a*64, 	!Character form of p1
     x$$	string_b*64, 	!Character form of p2
     x$$	string_delta_return*64 !Character form of subtracted result

$$integer i
$$character*80 line

$$status = lib$get_foreign(line)
$$if (line.eq.' ') then
$$  status = lib$get_foreign(string_a,'Enter 1st absolute time: ')
$$  status = lib$get_foreign(string_b,'Enter 2nd absolute time: ')
$$else
$$  i = index (line,',')
$$  string_a = line(1:i-1)
$$  string_b = line(i+1:)
$$end if
$$if (string_a.eq.' '.and.string_b.eq.' ') call exit
$$status = sys$bintim(string_a,time_a)
$$if (.not.status) 
     x$$	call error('Converting 1st parameter',status)
$$status = sys$bintim(string_b,time_b)
$$if (.not.status) 
     x$$	call error('Converting 2nd parameter',status)
$$status = lib$subx(time_B,time_A,delta_return,2)
$$if (.not.status) 
     x$$	call error('Performing p1 - p2',status)
$$status = sys$asctim(string_length,string_delta_return,
     x$$	delta_return,%val(0))
$$if (.not.status) 
     x$$	call error('Generating return ascii time',status)
$$status = lib$set_symbol('DELTA_RETURN',
     x$$	string_delta_return(1:string_length))
$$if (.not.status) 
     x$$	call error('DELTA_RETURN could not be created',status)
$$call exit(status)
$$end

$$subroutine error(message,code)

$$integer	lib$signal	!Signals error, producing error messages

$$integer	code,		!Error message code returned from routines
     x$$	len		!Built in routine to return length of string
$$character message*(*)	!Error message to be outputted on SYS$OUTPUT

$$print 10,message
10$$format(1x,'Error ',a<len(message)>,', reason follows:')
$$call lib$signal(%val(code))
$$return
$$end
-- 
Don    |Raytheon Company, Submarine Signal Division, Portsmouth, RI
Borsay |ARPAnet: d2b%rayssd.RAY.COM@a.cs.uiuc.edu
       |UUCPmail: {allegra, decvax!brunix, linus!raybed2}!rayssd!d2b
