Operating System - OpenVMS
1753849 Members
7927 Online
108807 Solutions
New Discussion юеВ

Lexical F$DELTA_TIME and "DCL" format selector

 
SOLVED
Go to solution
Robert_Boyd
Respected Contributor

Lexical F$DELTA_TIME and "DCL" format selector

The V7.3-2 patches incorporated this 3rd parameter and it works beautifully. I just discovered a script of mine is breaking on an Alpha V8.2 system which has all the latest patch kits installed. The "DCL" parameter is generating this:

x = f$delta_time( f$time(), f$cvtime("+0-0:2","ABSOLUTE"),"DCL")
%DCL-W-SYMDEL, invalid symbol or value delimiter - check command syntax

Has this additional feature not been extended to V8.2 yet?

Thanks,
Robert
Master you were right about 1 thing -- the negotiations were SHORT!
12 REPLIES 12
John Gillings
Honored Contributor

Re: Lexical F$DELTA_TIME and "DCL" format selector

Robert,

This change was a result of your ITRC question in May 2005. I hassled Guy into implementing it ;-)

Since V8.2 had already been released at the time, Guy added the change to V8.3, and created updates for V7.3-2 and V8.2. I'm unsure if the V8.2 version ever got released into the wild. Make sure you're up to date with all DCL related patches.

If that fails, log a case with HP customer support asking for the V8.2 version of Guy's code (that's assuming they can find it!).

Good luck!
A crucible of informative mistakes
Guy Peleg
Respected Contributor
Solution

Re: Lexical F$DELTA_TIME and "DCL" format selector

Robert,

As far as I recall, I made the change
to V8.3 and backported it to all remedial
releases. So far, no DCL kit has been released for V8.2 so the feature did not
get a chance to "ship". Contact HP and ask
for the latest DCL remedial image for V8.2,
the new image will include the "DCL" keyword.

Guy
Dennis Couch
New Member

Re: Lexical F$DELTA_TIME and "DCL" format selector

If anyone is interested and needs the functionality (and hasn't duplicated it themselves yet!), I created a DELTA_TIME.COM command procedure that duplicates the functionality of the F$DELTA_TIME lexical function on older versions of VMS prior to the addition of F$DELTA_TIME. It's meant to be called from other procedures and has two required parameters like F$DELTA_TIME. Let me know if you'd like a copy.
Jess Goodman
Esteemed Contributor

Re: Lexical F$DELTA_TIME and "DCL" format selector

Or in those cases in which you know that your two input time values are less than 24 hours apart, you can just use one F$CVTIME call instead of F$DELTA.

$ EARLY = F$CVTIME(,,"TIME")
$ SHOW SYMBOL EARLY
$ LATER = F$CVTIME("+0-12:34:56",,"TIME")
$ SHOW SYMBOL LATER

$!Return delta time between EARLY and LATER
$ DELTA=F$CVTIME("''LATER'-''EARLY'",,"TIME")
$ SHOW SYMBOL DELTA

Try it. Believe it or not it works for all deltas < 24 hours, even if the day boundary is crossed.
I have one, but it's personal.
Joseph Huber_1
Honored Contributor

Re: Lexical F$DELTA_TIME and "DCL" format selector

And my f$delta_time implementation for older systems including the "DCL" argument (maybe good enough) is at
http://wwwvms.mppmu.mpg.de/~huber/util/main/f$delta_time.html

Binary for VMS 7.3-1 Alpha:
http://wwwvms.mppmu.mpg.de/util_root/exe/f$delta_time.exe
http://www.mpp.mpg.de/~huber
Robert_Boyd
Respected Contributor

Re: Lexical F$DELTA_TIME and "DCL" format selector

Jess,

That is a very interesting "magic"! I wrote a time difference calculating DCL procedure about 15 years ago -- now I've been able to shorten it considerably.

I wanted a procedure that is completely portable, so I've updated it to use F$DELTA_TIME when possible.

I'm attaching it here and will also post it on dcl.OpenVMS.org

Robert
Master you were right about 1 thing -- the negotiations were SHORT!
Robert_Boyd
Respected Contributor

Re: Lexical F$DELTA_TIME and "DCL" format selector

Guy,

Thanks for the pointer -- I'll contact Support this week and ask about the DCL patch update for V8.2.

As far as I can tell it didn't make it into the VMS82A_UPDATE V5.0 kit and I don't see a separate DCL kit so far.

Robert
Master you were right about 1 thing -- the negotiations were SHORT!
John Gillings
Honored Contributor

Re: Lexical F$DELTA_TIME and "DCL" format selector

Robert,

If your objective is to shorten the procedure, for pre F$DELTA_TIME versions, here are two possibilities. The attachment is "clean" DCL which determines the delta time by successive approximation using simple iteration on each field in the time. It's fairly obvious what it's doing.

For your amusement, the following is probably close to the shortest (and fastest?) possible procedure to do the job. It calculates the difference between absolute times P2-P1 (where P1 is required to be less than P2, not checked). Believe it or not, it's based on very sound theory and will work on all versions from V5 up for all pairs of times within the 10000 day range up to 20-OCT-9165 18:42:01.36. Although technically it uses an undocumented and unsupported trick, I'd be astonished if engineering ever breaks it.

$ ON WARNING THEN EXIT
$ tt=F$CVTIME(p1)
$ GOSUB x
$ b0=d
$ tt=F$CVTIME(p2)
$ GOSUB x
$ b1=d
$ d[32,32]=%XF0000000
$ d[0,32]=0
$ l0=F$CVUI(0,30,b0)
$ l1=F$CVUI(0,30,b1)
$ IF l0.LT.l1
$ THEN
$ d[0,30]=.NOT.((l1-l0).AND.%X3FFFFFFF)
$ d[30,30]=.NOT.(F$CVUI(30,30,b1)-F$CVUI(30,30,b0))
$ ELSE
$ d[0,30]=.NOT.((%X40000000+l1-l0).AND.%X3FFFFFFF)
$ d[30,30]=.NOT.(F$CVUI(30,30,b1)-F$CVUI(30,30,b0)-1)
$ ENDIF
$ delta==F$FAO("!%D",F$CVUI(32,32,F$FAO("!AD",8,d)))
$ SHOW SYM delta
$ EXIT
$ x:
$ d[32,32]=0
$ d[0,32]=0
$ b=60
$ Loop: d[b,1]=1
$ IF F$CVTIME(F$FAO("!%D",F$CVUI(32,32,F$FAO("!AD",8,d)))).GTS.tt THEN d[b,1]=0
$ b=b-1
$ IF b.GT.0 THEN GOTO loop
$ RETURN



(If someone asks nicely I'll post the version with comments explaining how it works ;-)
A crucible of informative mistakes
Jon Pinkley
Honored Contributor

Re: Lexical F$DELTA_TIME and "DCL" format selector

John Gillings,

I would be interested in seeing the commented version of your version of an f$delta_time replacement using undocumented/unsupported features.

I made a slight modification to it, so it will use Jess Goodman's shortcut for delta times that are less than 24 hours. For those cases, that should be "faster".

Here's the modified version (with no comments).

$! dcl delta time calculator
$! based on http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1089731
$! using John Gillings' 64 bit binary time manipulation in DCL
$! and Jess Goodman's shortcut for delta times less than 24 hours
$!
$! p1 Earlier date_time
$! p2 Later date_time
$!
$! first check if the difference is < 24 hours, if so we can use shortcut
$
$ if f$cvtime("''p1'+1-0") .ges. f$cvtime(p2)
$ then ! use f$cvtime shortcut
$ EARLY = F$CVTIME(p1,,"TIME")
$ !SHOW SYMBOL EARLY
$ LATER = F$CVTIME(p2,,"TIME")
$ !SHOW SYMBOL LATER
$ !Return delta time between EARLY and LATER
$ DELTA==" 0 " + F$CVTIME("''LATER'-''EARLY'",,"TIME")
$ else
$ ON WARNING THEN EXIT
$ tt=F$CVTIME(p1)
$ GOSUB x
$ b0=d
$ tt=F$CVTIME(p2)
$ GOSUB x
$ b1=d
$ d[32,32]=%XF0000000
$ d[0,32]=0
$ l0=F$CVUI(0,30,b0)
$ l1=F$CVUI(0,30,b1)
$ IF l0.LT.l1
$ THEN
$ d[0,30]=.NOT.((l1-l0).AND.%X3FFFFFFF)
$ d[30,30]=.NOT.(F$CVUI(30,30,b1)-F$CVUI(30,30,b0))
$ ELSE
$ d[0,30]=.NOT.((%X40000000+l1-l0).AND.%X3FFFFFFF)
$ d[30,30]=.NOT.(F$CVUI(30,30,b1)-F$CVUI(30,30,b0)-1)
$ ENDIF
$ delta==F$FAO("!%D",F$CVUI(32,32,F$FAO("!AD",8,d)))
$ endif
$
$ SHOW SYMBOL/GLOBAL DELTA
$ EXIT
$ x:
$ d[32,32]=0
$ d[0,32]=0
$ b=60
$ Loop: d[b,1]=1
$ IF F$CVTIME(F$FAO("!%D",F$CVUI(32,32,F$FAO("!AD",8,d)))).GTS.tt THEN d[b,1]=0
$ b=b-1
$ IF b.GT.0 THEN GOTO loop
$ RETURN
it depends