View previous topic :: View next topic
|
Author |
Message |
GaneshKarunyarajan
New User
Joined: 12 Apr 2005 Posts: 13
|
|
|
|
I'm now in the process of writing the Rexx program to read a file that contains Hex values. I have to get some values and convert them into Decimal. Can anyone suggest how to read only few col in file that is in hex values.
Any suggestions would be really greatfull |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
GaneshKarunyarajan wrote: |
I'm now in the process of writing the Rexx program to read a file that contains Hex values. I have to get some values and convert them into Decimal. Can anyone suggest how to read only few col in file that is in hex values.
Any suggestions would be really greatfull |
Would these "hex values" happen to be packed decimal data? |
|
Back to top |
|
|
GaneshKarunyarajan
New User
Joined: 12 Apr 2005 Posts: 13
|
|
|
|
This is how the file looks like.
Command ===>
********************************* Top of Data **
...Ã.....INTEGER ....
I will have to read this and convert to a decimal value. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You need to re-post that data as shown using HEX ON. Also, please use the Code tag (which preserves alignment and greatly improves readability.
After properly posting the input, then post the desired output from that input.
There is a Preview feature that will let you see your post as it will appear to the forum (rather than how it appears in the Reply editor). |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Additionally,
There is no such thing as a "hexadecimal file" on the mainframe (or if you prefer, every file is stored in hexadecimal).
There are alphabetic, alphanumeric, and multiple numeric data formats - all have hexadecimal values. |
|
Back to top |
|
|
GaneshKarunyarajan
New User
Joined: 12 Apr 2005 Posts: 13
|
|
|
|
Here is the file with hex on. As suggested file with CODE TAG.
Code: |
Command ===>
**********************
---------------------
...Ã.....INTEGER ....
030601000CDECCCD400004
19163500B9535759004000
---------------------
|
|
|
Back to top |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
Look at the substr() and x2d() functions in Rexx. These will be a start. Then you may want to look at other string handling functions (pos, left, right, and others) as well as other conversion functions (d2x, and others)
You will have to read the whole record and break it up with substr.
When you get more comfortable with Rexx, you will probably want to use the Parse instruction instead of substr() because it is easier to read and more efficient. |
|
Back to top |
|
|
GaneshKarunyarajan
New User
Joined: 12 Apr 2005 Posts: 13
|
|
|
|
I will be start with MBabu's suggestion and work on it. Thanks a lot for your help for now. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
How big is the file? |
|
Back to top |
|
|
GaneshKarunyarajan
New User
Joined: 12 Apr 2005 Posts: 13
|
|
|
|
not a very big file.. 10 - 20 line file |
|
Back to top |
|
|
GaneshKarunyarajan
New User
Joined: 12 Apr 2005 Posts: 13
|
|
|
|
It is a requirement that I'm working on.
I used SUBSTR() function and then used X2D() but
Here is what I'm getting the error.
DD = SUBSTR(LINE,1,2)
a = x2d(DD)
When I run the routine, I'm getting
"Error running HEX2DEC, line 45: Incorrect call to routine " |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
a = x2d(c2x(dd)) |
|
Back to top |
|
|
GaneshKarunyarajan
New User
Joined: 12 Apr 2005 Posts: 13
|
|
|
|
prino,
It worked.. thank you... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Several "extra" replies have been deleted.
Ganesh,
Good to hear it is working - thanks for letting us know
d |
|
Back to top |
|
|
|