Computing.Net > Forums > OpenVMS > F$INTEGER problem

F$INTEGER problem

Reply to Message Icon

Original Message
Name: amsedelm
Date: May 14, 2008 at 13:27:54 Pacific
Subject: F$INTEGER problem
OS: Open/VMS
CPU/Ram: not sure
Model/Manufacturer: HP Alpha Server
Comment:

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.
Mike

Michael Ledesma
System Administrator
Petro Heating Oil Svc's


Report Offensive Message For Removal


Response Number 1
Name: Joseph.Huber
Date: May 15, 2008 at 00:07:54 Pacific
Reply: (edit)

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 Offensive Follow Up For Removal

Response Number 2
Name: amsedelm
Date: May 15, 2008 at 06:45:43 Pacific
Reply: (edit)

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.
Mike

Michael Ledesma
System Administrator
Petro Heating Oil Svc's


Report Offensive Follow Up For Removal

Response Number 3
Name: Joseph.Huber
Date: May 15, 2008 at 10:43:45 Pacific
Reply: (edit)

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 Offensive Follow Up For Removal

Response Number 4
Name: amsedelm
Date: May 16, 2008 at 07:53:42 Pacific
Reply: (edit)

Thanks, Joseph. You have alot of good stuff there. Much appreciated.
Mike

Michael Ledesma
System Administrator
Petro Heating Oil Svc's


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: F$INTEGER problem

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge