Date to quadword in DCL????

110 views
Skip to first unread message

derek pietro

unread,
Jul 1, 2005, 10:19:33 AM7/1/05
to
Can someone point me to something that might lead me to the path of
converting a date string to a binary quadword in DCL? (If its possible
there)
If it cant be done in DCL I would like simply to know that as well
Thanks!

Keith Cayemberg

unread,
Jul 1, 2005, 11:06:42 AM7/1/05
to

David J Dachtera

unread,
Jul 2, 2005, 4:37:28 PM7/2/05
to

DCL only deals in longword integers.

That said, see Keith's post for a link to a post form this group via
Google.

Perhaps if you could let us know what you need to do with that info.,
someone here could offer better suggestions.

--
David J Dachtera
dba DJE Systems
http://www.djesys.com/

Unofficial OpenVMS Hobbyist Support Page:
http://www.djesys.com/vms/support/

Unofficial Affordable OpenVMS Home Page:
http://www.djesys.com/vms/soho/

Unofficial OpenVMS-IA32 Home Page:
http://www.djesys.com/vms/ia32/

Coming soon:
Unofficial OpenVMS Marketing Home Page

derek pietro

unread,
Jul 5, 2005, 1:45:45 PM7/5/05
to
I must copy files named like "21Jun200511004578 .00001" from an Alpha
7.2 vms to linux. During that process I must rename the file at the
destination - or on its way there - to 46260684457800000.00001.
All of the above is a requirement.

If I typed all that properly, one could see that the first filename is
a dec timestamp (up to but not including the period) and the
destination filename is the quadword representation of that filename.
(the .00001 on the end is a count of the number of files sharing the
base filename and is not relavant to the question at hand)

I'd prefer to manipulate the filename conversion on the VMS side of
things - it appears theres no way in DCL to convert from "date" to
"quadword" hence it needs to be done in "C" - my only other choice of
things to work in.

My original question was aimed at converting a list of quadwords to
their respective file names - but I gave up on it for reasons of no
importance here.

I have been unsuccessfully trying to locate documentation on
"sys$bintim" - which some other posting lays claim might do what I
need.

Can someone point me to a doc that describes $bintim or something else
that would take a (properly) formatted date/time string and convert it
to its quadword?

Thanks!

JF Mezei

unread,
Jul 5, 2005, 2:41:48 PM7/5/05
to
derek pietro wrote:
>
> I must copy files named like "21Jun200511004578 .00001" from an Alpha
> 7.2 vms to linux. During that process I must rename the file at the
> destination - or on its way there - to 46260684457800000.00001.
> All of the above is a requirement.
>
> If I typed all that properly, one could see that the first filename is
> a dec timestamp (up to but not including the period)

Not quite. it would have to be

"21-Jun-2005 11:00:45.78" to be a valid time stamp that can be understood by
routines such as SYS$BINTIM

Also note that in your text above, you have a space between the 8 and the dot.
Is that just a typo ?

Since quadword is not native to unix, is there a reason why you absolutely
need "quadword" instead of using unix time ?

If you have a recent/patched version of VMS, there should be Guy Peleg's F$DELTA_TIME

> http://www.google.com/groups?q=g:thl4005862252d&dq=&hl=xx-elmer&lr=&ie=UTF-8&newwindow=1&safe=off&selm=3F0D7BFC.383CB534%40hp.com

You could then do F$DELTA_TIME( current, "01-JAN-1970:00:00:00.00") and then
proceed to parse the output for number of days (multiply by 86400), number of
hours (multiply by 3600) minutes (*6) and seconds, add it together and you
have unix time.

> I have been unsuccessfully trying to locate documentation on
> "sys$bintim" - which some other posting lays claim might do what I
> need.


HELP SYS $BINTIM

It is also in the systems services manual.

#include descrip

$DESCRIPTOR(mytime_desc,"");
char *mytime = "05-Jul-2005 14:36:28.00";
unsigned int mytime_bin[2];

mytime_desc.dsc$a_pointer = mytime ;
mytime_desc.dsc$w_length = strlen(mytime);
status = SYS$BINTIM( &mytime_desc, &mytime_bin[0] );

mytime_bin then has the binary value in it. (8 bytes).


You'll also need to include starlet.h to get the prototype for sys$bintim.

Also, if in VAX, you need to manually add:
#define SYS$BINTIM sys$bintim

because on VAX, the engineers forgot to include the definition for the
uppercase version of the system services. (as well as lib$ routines)

Stanley F. Quayle

unread,
Jul 5, 2005, 2:40:46 PM7/5/05
to
On 5 Jul 2005 at 10:45, derek pietro wrote:
> Can someone point me to a doc that describes $bintim or something else
> that would take a (properly) formatted date/time string and convert it
> to its quadword?

You're looking for the "HP OpenVMS System Services Reference Manual",
which is hidden under "Systems Documentation" on the web site. And
the $BINTIM function is hidden under "SYS$BINTIM":

http://h71000.www7.hp.com/doc/82FINAL/4527/4527pro_012.html#index_x_10
3

(pardon the wrap)

--Stan Quayle
Quayle Consulting Inc.

----------
Stanley F. Quayle, P.E. N8SQ +1 614-868-1363
8572 North Spring Ct., Pickerington, OH 43147 USA
stan-at-stanq-dot-com http://www.stanq.com
"OpenVMS, when downtime is not an option"


David J Dachtera

unread,
Jul 5, 2005, 8:20:15 PM7/5/05
to
"Stanley F. Quayle" wrote:
>
> On 5 Jul 2005 at 10:45, derek pietro wrote:
> > Can someone point me to a doc that describes $bintim or something else
> > that would take a (properly) formatted date/time string and convert it
> > to its quadword?
>
> You're looking for the "HP OpenVMS System Services Reference Manual",
> which is hidden under "Systems Documentation" on the web site. And
> the $BINTIM function is hidden under "SYS$BINTIM":
>
> http://h71000.www7.hp.com/doc/82FINAL/4527/4527pro_012.html#index_x_10
> 3
>
> (pardon the wrap)

Of course, calling OpenVMS System Services from DCL is rather a
challenge...

Based on Derek's post, it seems he could use the technique cited in a
Google URL in another post, just needing to convert the result back to a
string, possibly with F$FAO() to ensure the proper target format.

Thinking "out loud"...

derek pietro

unread,
Jul 6, 2005, 10:02:06 AM7/6/05
to
Well, I've gotten this far, heres where I'm at.
The totally stripped down problem is to take a date string and obtain
its quadword representation as a string.
my attempt below which provides output below that.
Note that I am "stuck" at converting the Hex to the quadword as a
string.
Perhaps my approach is wrong, but I dont know squat about VMS and my
"C" is real rusty.

Can someone lead me thru something that will get me to a quadword in a
string?
(The commented descriptor is the string fed to the "main" as argv[1],
the expected output would be "46260684457800000" in a string"
Thanks....
==========
main(int argc, char *argv[])
{
// $DESCRIPTOR(datebuf, "21-jun-2005 11:00:45.78");
$DESCRIPTOR(datebuf, "dummy");
datebuf.dsc$a_pointer = strdup(argv[1]);
datebuf.dsc$w_length = strlen(datebuf.dsc$a_pointer) ;

int i, stat;
int SYS$BINTIM();
static long bintim[2];
char quad0[64];
char quad1[64];
char quad[64];
// __int64 dquad;
long dquad;

if (argc < 1) {
printf ("Usage $%s <date str> \n", argv[0]);
return 268435456;
} else {
printf(" instr is %s \n", argv[1]);
SYS$BINTIM(&datebuf, bintim);
printf("quad is %x %x\n", bintim[1], bintim[0]);

sprintf(quad0, "%x", bintim[1]);

sprintf(quad1, "%8x", bintim[0]);
strcpy(quad, "0x");
strcat(quad, quad0);
strcat(quad, quad1);
printf("quad %s\n", quad);
}
}
========
My current output from the above.
===========
$ @run
instr is 21-jun-2005 11:00:45.78
quad is a459d8 f02c7140
quad 0xa459d8f02c7140

Rob Brown

unread,
Jul 6, 2005, 11:41:13 AM7/6/05
to
On Wed, 6 Jul 2005, derek pietro wrote:

> Well, I've gotten this far, heres where I'm at.
> The totally stripped down problem is to take a date string and obtain
> its quadword representation as a string.
> my attempt below which provides output below that.
> Note that I am "stuck" at converting the Hex to the quadword as a
> string.

...

> Can someone lead me thru something that will get me to a quadword in a
> string?
> (The commented descriptor is the string fed to the "main" as argv[1],
> the expected output would be "46260684457800000" in a string"

...

> sprintf(quad0, "%x", bintim[1]);
>
> sprintf(quad1, "%8x", bintim[0]);
> strcpy(quad, "0x");
> strcat(quad, quad0);
> strcat(quad, quad1);
> printf("quad %s\n", quad);

...

> ========
> My current output from the above.
> ===========
> $ @run
> instr is 21-jun-2005 11:00:45.78
> quad is a459d8 f02c7140
> quad 0xa459d8f02c7140

Looks OK to me. The Hex values you print are equivalent to the
decimal value you said you expected.

Converting to decimal ASCII instead of the hexadecimal ASCII is
another question. I am still stuck in the 32-bit world so I haven't
had to deal with this.

I note that you had declared something __int64 and then commented it
out and replaced it with a long. Is 64-bit unsigned arithmetic
unavailable to you? Does using printf ("%d", ( unsigned__int64) quad)
not do what is desired? If you are working on alpha, my DECC V5.7
manuals make me think that it should have worked. Try #include
<ints.h>.

If not, my V7.1 manuals do not have something that will do the
conversion for you. You would have to hand code the conversion to
decimal, maybe using LIB$EDIV. (Since LIB$EDIV only handles a
longword quotient, you will have to carefully build up your dividend
piece by piece.)

hth


--

Rob Brown b r o w n a t g m c l d o t c o m
G. Michaels Consulting Ltd. (866)438-2101 (voice) toll free!
Edmonton (780)438-9343 (voice)
(780)437-3367 (FAX)
http://gmcl.com/

Tom Linden

unread,
Jul 6, 2005, 12:11:07 PM7/6/05
to

With minor modifications the following will work
http://h18000.www1.hp.com/support/asktima/appl_tools/00918C23-B4FD7AA0-1C0069.html
assuming you have a PL/I compiler.
The following will instruct you how to pass an arguement to the program
http://h18000.www1.hp.com/support/asktima/appl_tools/0094D650-7F755220-1C01E7.html
or you could use a symbol as in
http://h18000.www1.hp.com/support/asktima/appl_tools/0091A38D-9C725560-1C01E7.html

Z

unread,
Jul 6, 2005, 1:48:43 PM7/6/05
to
derek pietro wrote:
> Can someone lead me thru something that will get me to a quadword in a
> string?

#include <stdio.h>

main()
{
char str[17];
unsigned long long qword = 0x0123456789ABCDEF;

sprintf(str, "%016llX", qword); /* %-zero-one-six-ell-ell-ex */
printf("str: %s\n", str);
}

Jeff Chimene

unread,
Jul 6, 2005, 1:56:07 PM7/6/05
to
derek pietro wrote:
> Well, I've gotten this far, heres where I'm at.
> The totally stripped down problem is to take a date string and obtain
> its quadword representation as a string.
> my attempt below which provides output below that.
> Note that I am "stuck" at converting the Hex to the quadword as a
> string.
> Perhaps my approach is wrong, but I dont know squat about VMS and my
> "C" is real rusty.
>

Hi Derek,

I just want to make sure of the requirements here - are you
/absolutely sure/ the destination system wants a date based on the VMS
epoch? Since the destination is a *nix, that requirement seems
surprising. I'd be more comfortable if they were asking for a date based
on the standard *nix epoch. Perhaps those on the other end of the wire
don't know the difference?

Cheers,
jec

JF Mezei

unread,
Jul 6, 2005, 1:56:21 PM7/6/05
to
derek pietro wrote:
> static long bintim[2];


this needs to be unsigned. Otherwise, one or both words may show up as
negatives when you use sprintf.


Also, why not simply use:

sprintf(buffer,"%08x%08x", bintim[1], bintim[0]); ?

Or you could put a separatator such as "_" between the two longs words to make
it easier to see both longwords separately.

David J Dachtera

unread,
Jul 6, 2005, 9:19:48 PM7/6/05
to

Look up LIB$SET_SYMBOL in the documentation or the on-line HELP (HELP
RTL LIB$ LIB$SET_SYMBOL). That will pass the value into the DCL
environment where you can further manipulate it in the command language
(concatentate additional string data, use symbol substitution, etc).

pr...@prep.synonet.com

unread,
Jul 6, 2005, 1:48:44 PM7/6/05
to
David J Dachtera <djesys...@comcast.net> writes:

> "Stanley F. Quayle" wrote:

>> On 5 Jul 2005 at 10:45, derek pietro wrote:
>> > Can someone point me to a doc that describes $bintim or something
>> > else that would take a (properly) formatted date/time string and
>> > convert it to its quadword?
>
>> You're looking for the "HP OpenVMS System Services Reference
>> Manual", which is hidden under "Systems Documentation" on the web
>> site. And the $BINTIM function is hidden under "SYS$BINTIM":

>> http://h71000.www7.hp.com/doc/82FINAL/4527/4527pro_012.html#index_x_103

>> (pardon the wrap)

> Of course, calling OpenVMS System Services from DCL is rather a
> challenge...

> Based on Derek's post, it seems he could use the technique cited in
> a Google URL in another post, just needing to convert the result
> back to a string, possibly with F$FAO() to ensure the proper target
> format.

> Thinking "out loud"...

Wasn't this done ages ago by someone by doing examanes and deposits to
`the right place' in DCL? About the time of DCLCMPLT perhaps...

--
Paul Repacholi 1 Crescent Rd.,
+61 (08) 9257-1001 Kalamunda.
West Australia 6076
comp.os.vms,- The Older, Grumpier Slashdot
Raw, Cooked or Well-done, it's all half baked.
EPIC, The Architecture of the future, always has been, always will be.

derek pietro

unread,
Jul 7, 2005, 7:59:24 AM7/7/05
to
Thank you all (again - as this is not my first plea for help here) for
the pointers and info on this issue.
Between all posts on this and some digging as a result of things read
here I've now a workable solution to my problem.
Again - thanks all!

Reply all
Reply to author
Forward
0 new messages