Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!necntc!rayssd!d2b From: d2b@rayssd.RAY.COM (Donald A. Borsay) Newsgroups: comp.os.vms Subject: Re: Calculating Elapsed Time From DCL. Message-ID: <1471@rayssd.RAY.COM> Date: Fri, 21-Aug-87 12:33:21 EDT Article-I.D.: rayssd.1471 Posted: Fri Aug 21 12:33:21 1987 Date-Received: Sun, 23-Aug-87 01:47:58 EDT References: <870805075119.03q@VLSI.JPL.NASA.GOV> Sender: d2b@rayssd.RAY.COM (Donald A. Borsay @ Raytheon Company, Portsmouth RI) Reply-To: d2b@rayssd.RAY.COM (Donald A. Borsay) Distribution: world Organization: Raytheon Company, Portsmouth RI Lines: 99 Summary: Try this program 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,', 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