MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Writing to a PS in hex format

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
arunmr4
Beginner


Joined: 19 Dec 2005
Posts: 23
Topics: 8

PostPosted: Mon Dec 26, 2005 11:49 pm    Post subject: Writing to a PS in hex format Reply with quote

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
View user's profile Send private message Send e-mail
amit4u79
Beginner


Joined: 24 Oct 2005
Posts: 109
Topics: 36
Location: India

PostPosted: Tue Dec 27, 2005 4:12 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Yahoo Messenger
dtf
Beginner


Joined: 10 Dec 2004
Posts: 110
Topics: 8
Location: Colorado USA

PostPosted: Tue Dec 27, 2005 11:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
arunmr4
Beginner


Joined: 19 Dec 2005
Posts: 23
Topics: 8

PostPosted: Wed Dec 28, 2005 2:52 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Dec 28, 2005 8:48 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
arunmr4
Beginner


Joined: 19 Dec 2005
Posts: 23
Topics: 8

PostPosted: Thu Dec 29, 2005 3:05 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Dec 29, 2005 5:50 am    Post subject: Reply with quote

arunmr4,

Check this link for a detailed explanation of INTERPRET

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ4A330/3.8?DT=20020521161835

The C & D are used to denote the signs positive and negative respectively.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
arunmr4
Beginner


Joined: 19 Dec 2005
Posts: 23
Topics: 8

PostPosted: Fri Dec 30, 2005 12:57 am    Post subject: Reply with quote

Thanks a lot Kolusu
Arun
Back to top
View user's profile Send private message Send e-mail
arunmr4
Beginner


Joined: 19 Dec 2005
Posts: 23
Topics: 8

PostPosted: Wed Jan 04, 2006 9:37 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Mervyn
Moderator


Joined: 02 Dec 2002
Posts: 415
Topics: 6
Location: Hove, England

PostPosted: Thu Jan 05, 2006 4:25 am    Post subject: Reply with quote

Arun,

If DEC_NUM contains "2005" then the INTERPRET will yield the statement "PACK_NUM = '2005C'X". Take a look at the "Hexadecimal Strings" section here:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ4A350/2.1.3?SHELF=&DT=20040623084642&CASE=
_________________
The day you stop learning the dinosaur becomes extinct
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Thu Jan 05, 2006 9:31 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
arunmr4
Beginner


Joined: 19 Dec 2005
Posts: 23
Topics: 8

PostPosted: Sun Jan 08, 2006 9:24 pm    Post subject: Reply with quote

Thanks Mervyn and semigeezer.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group