Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
In DCL: how do I get only the numeric value when I use the lexical F$INTEGER? Because the output shows numeric, octal, and hex. Or, do I just cut out the Hex and Octal fields? Is there any easier way to add numbers? I'm a unix guy learning DCL.
Thanks.
MikeMichael Ledesma
System Administrator
Petro Heating Oil Svc's

What do You really mean ?
The result of i=f$integer(x) is an assignement/converion of x to a numerical symbol i.
Only the SHOW SYMBOL i displays the symbol in the 3 radices.If You want to see only the decimal value, use
write sys$output symbol
-or-
use the f$fao lexical function to display in any format wanted.

I'm writing a program to calculate epoch time from a date stamp. I used the f$integer lexical to convert the values to numeric so I could add them. Otherwise they were being concatenated. That's the only way I could figure it out. But, I'll try your suggestion. I'm new at DCL.
Thanks for your help.
MikeMichael Ledesma
System Administrator
Petro Heating Oil Svc's

An example to calculate seconds since midnight:
$ times="19:11:03"
$ h = f$integer(f$element(0,":",times))
$ m = f$integer(f$element(1,":",times))
$ s = f$integer(f$element(2,":",times))
$ seconds = (h*3600) + (m*60) + s
$ write sys$output h,":",m,":",s,"=",seconds$! date:
$ dates="1-JUN-2008"
$ dates = f$edit(dates,"UPCASE")
$ day=f$integer(f$cvtime(dates,"COMPARISON","DAY"))
$ mon=f$integer(f$cvtime(dates,"COMPARISON","MONTH"))
$ year=f$integer(f$cvtime(dates,"COMPARISON","YEAR"))
$ seconds=f$cvtime(dates,"COMPARISON","SECONDOFYEAR")
$ write sys$output dates,"=",day," ",mon," ",year,"=",seconds," sec"
Note: correct calculation of seconds since epoch is not easy to do in DCL, since You would have to take into account the leap-year algorithm.A more appropriate way to write a small program in a higher level language: get the date string from the command-line, use the ascii-to-numeric time functions, then convert the resulting numerical time to a string, output the string in a DCL symbol.
See some examples in my VMS utilities page at
http://wwwvms.mppmu.mpg.de/~huber/u...Look for the *time_t routines, and
$ h = f$integer(f$element(0,":",times))
$ m = f$integer(f$element(1,":",times))
$ s = f$integer(f$element(2,":",times))
$ seconds = (h*3600) + (m*60) + s
$ write sys$output h,":",m,":",s,"=",seconds$! date:
$ dates="1-JUN-2008"
$ dates = f$edit(dates,"UPCASE")
$ day=f$integer(f$cvtime(dates,"COMPARISON","DAY"))
$ mon=f$integer(f$cvtime(dates,"COMPARISON","MONTH"))
$ year=f$integer(f$cvtime(dates,"COMPARISON","YEAR"))
$ seconds=f$cvtime(dates,"COMPARISON","SECONDOFYEAR")
$ write sys$output dates,"=",day," ",mon," ",year,"=",seconds," sec"
Note: correct calculation of seconds since epoch is not easy to do in DCL, since You would have to take into account the leap-year algorithm.A more appropriate way to write a small program in a higher level language: get the date string from the command-line, use the ascii-to-numeric time functions, then convert the resulting numerical time to a string, output the string in a DCL symbol.
See some examples in my VMS utilities page at
http://wwwvms.mppmu.mpg.de/~huber/u...Look for the *time_t routines, and vmstime_to_time_t_m.C in the main/ directory.

Thanks, Joseph. You have alot of good stuff there. Much appreciated.
MikeMichael Ledesma
System Administrator
Petro Heating Oil Svc's

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |