Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert decimal value to hexidecimal char

Status
Not open for further replies.

ConDamage

Programmer
Jul 3, 2007
4
0
0
ZA
Hi.

I move an ebcdic char (hex A8) to a pic x comp-x value h"0" field which returns it's decimal value 168. I need to convert this value, or any other 3 digit value back into a pic x ebcdic character.

any help will be greatly appreciated!
 
How does reversing the process you described work out?
 
Have a look at the ORD and CHAR intrinsic functions.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Glen: The program doesn't compile, doesn't even return valid errors, when I try and move a text char like "y" to the comp-x field.

PHV: thx bro, I'll have a look.

 
PHV: I used the char func and it looks like it's gonna work! It doesn't return the correct char, in this case "y", but it does stick to the sequence.

when I pass 168 thru this function it returns "x" which is in pos 167 so all I'm gonna do is add 1 to my decimal before getting it's char.

thx again for the help :)
 
Depending on your compiler vendor, there may be COBOL sytax or directives that will cause the 1 to be added automatically.
 
Hi CD,

If you're on an IBM MF and use COBOLII or better and your input field is in a COMP field of 2 bytes, you can try this:

05 your-ip pic 9(003)comp.
05 your-re redefines
your-ip pic x(002).
05 your-op pic x(001).


move your-re(2:1) to your-op.


Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
 
CD,

Forgot to mention: This assumes your-ip will never exceed 255 (X'FF').

Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
 
thx for the help Jack :)

I'm actually running my code on win2003 and the input I'm getting is from MVS mainframes. The "function char" sorted out my initial problem so now the only one I have left is getting confirmation that the data I receive is in fact what I originally thought it was.

Can't go more into it, legal stuff and what not :)

thx again for the help all!
 
Thanx for the update CD.

Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top