# F\$INTEGER problem

HP Alpha Server
May 14, 2008 at 13:27:54
Specs: Open/VMS , not sure

 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 LedesmaSystem AdministratorPetro Heating Oil Svc's

See More: F\$INTEGER problem

#1
May 15, 2008 at 00:07:54

 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.

Report •

#2
May 15, 2008 at 06:45:43

 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 LedesmaSystem AdministratorPetro Heating Oil Svc's

Report •

#3
May 15, 2008 at 10:43:45

 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.

Report •

Related Solutions

#4
May 16, 2008 at 07:53:42

 Thanks, Joseph. You have alot of good stuff there. Much appreciated.MikeMichael LedesmaSystem AdministratorPetro Heating Oil Svc's

Report •