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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

F$INTEGER problem

Reply to Message Icon

Name: amsedelm
Date: May 14, 2008 at 13:27:54 Pacific
OS: Open/VMS
CPU/Ram: not sure
Product: 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



Sponsored Link
Ads by Google

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

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.


0

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

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


0

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

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.


0

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

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

Michael Ledesma
System Administrator
Petro Heating Oil Svc's


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: F$INTEGER problem

check if input has all integer char www.computing.net/answers/openvms/check-if-input-has-all-integer-char/452.html

more DCL help www.computing.net/answers/openvms/more-dcl-help-/228.html

errorhandling in VMS files www.computing.net/answers/openvms/errorhandling-in-vms-files/298.html