View previous topic :: View next topic |
Author |
Message |
arunmr4 Beginner
Joined: 19 Dec 2005 Posts: 23 Topics: 8
|
Posted: Mon Dec 26, 2005 11:49 pm Post subject: Writing to a PS in hex format |
|
|
Hi,
I need to write to a PS a numeric value (for eg. 2005) so that it gets stored in hexadecimal format. Is there a way to do this using Rexx.
Thank you |
|
Back to top |
|
 |
amit4u79 Beginner
Joined: 24 Oct 2005 Posts: 109 Topics: 36 Location: India
|
Posted: Tue Dec 27, 2005 4:12 am Post subject: |
|
|
Hi Arun,
The simplest way I can think is to convert your decimal to hexadecimal and write the output to the file :
/* REXX */
say 'enter your decimal value :'
pull dec_val
amit = d2x(dec_val)
say amit
Exit
Here get the variable dec_val as the input digit and then write the variable amit to the file which will be written to the file in an equivalent hex format. _________________ I did not fail; I have found 10,000 ways that would not work - Albert Einstein. |
|
Back to top |
|
 |
dtf Beginner
Joined: 10 Dec 2004 Posts: 110 Topics: 8 Location: Colorado USA
|
Posted: Tue Dec 27, 2005 11:51 pm Post subject: |
|
|
I guess I am not really sure what you want to do........
This value in Zone decimal would be X'F2F0F0F5' if you were to display it in HEX format in ISPF. It would take up 4 bytes.
The question seems to indicate that you'd like it stored in binary. Like a COMP field in COBOL. Is that correct?
Hexadecimal is really just an external shorthand for binary. The hex representation of this number which would fit into a halfword (2 bytes) is X'07DF' is that what you want?
________
roor bong
Last edited by dtf on Tue Feb 01, 2011 2:04 pm; edited 1 time in total |
|
Back to top |
|
 |
arunmr4 Beginner
Joined: 19 Dec 2005 Posts: 23 Topics: 8
|
Posted: Wed Dec 28, 2005 2:52 am Post subject: |
|
|
Thanks amit but what I wan't to do is to store the value in packed format in the PS. Can you help dtf. Usually what I do now is to open the PS, do a hex and edit the values. And when I do a hex off the changes will be reflected as special characters.
Thanks |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Dec 28, 2005 8:48 am Post subject: |
|
|
arunmr4,
Try this
Code: |
/* REXX CONVERT NUMBER TO PACKED DECIMAL */
ARG DEC_NUM
IF DATATYPE(DEC_NUM) ^= 'NUM' THEN
RETURN ''
IF DEC_NUM < 0 THEN
INTERPRET "PACK_NUM = '"ABS(DEC_NUM)"D'X"
ELSE
INTERPRET "PACK_NUM = '"DEC_NUM"C'X"
RETURN PACK_NUM
|
_________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
arunmr4 Beginner
Joined: 19 Dec 2005 Posts: 23 Topics: 8
|
Posted: Thu Dec 29, 2005 3:05 am Post subject: |
|
|
Thanks a lot kolusu. Its working for me. If you have time please explain the statement
INTERPRET "PACK_NUM = '"DEC_NUM"C'X" |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
arunmr4 Beginner
Joined: 19 Dec 2005 Posts: 23 Topics: 8
|
Posted: Fri Dec 30, 2005 12:57 am Post subject: |
|
|
Thanks a lot Kolusu
Arun |
|
Back to top |
|
 |
arunmr4 Beginner
Joined: 19 Dec 2005 Posts: 23 Topics: 8
|
Posted: Wed Jan 04, 2006 9:37 pm Post subject: |
|
|
Hi Kolusu,
In the statement "PACK_NUM = '"DEC_NUM"C'X" what is X. Is it a key word. What else can come in its place. I need to explain this to my colleagues. If you can just provide a link that will do.
Thanks,
Arun |
|
Back to top |
|
 |
Mervyn Moderator

Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
|
Back to top |
|
 |
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Thu Jan 05, 2006 9:31 am Post subject: |
|
|
Usually, when writing a visually complex interpret statement like this, it is good to do something like this: Code: | cmd = "PACK_NUM = '"ABS(DEC_NUM)"D'X"
say cmd
interpret cmd |
That will show you the rexx statement being interpreted.
For a simple case like this, I'd prefer the value() function over interpret, but I guess they amount to the same thing. |
|
Back to top |
|
 |
arunmr4 Beginner
Joined: 19 Dec 2005 Posts: 23 Topics: 8
|
Posted: Sun Jan 08, 2006 9:24 pm Post subject: |
|
|
Thanks Mervyn and semigeezer. |
|
Back to top |
|
 |
|
|