A lot of my students have the same problem so I explain it this way:
The x2y functions all take character strings. If that character string is a
valid value in the base indicated by the 'x' in the function name, it will be
converted into a string representation of that value (if possible) in the 'y' base.
A common problem is when you want to find the decimal equivalent of a hex value.
The temptation is mighty strong to code dec=X2D('2FC8'x). As soon as you
encode the hex value _as_a_hex_constant_ Rexx dutifully converts that string
into its internal representation, and that is the value that X2D() sees.
Basically, I tell them not to over-think the problem. It's simply string-in,
string-out, and the name tells you what Rexx expects and what he will return.
-Chip-
On 4/30/10 14:42 Kris Buelens said:
Often it is not obvious which "x2y" conversion function has to be used.
For example; do you need X2C or C2X?
Therefore I wrote an XTOX EXEC that tries all REXX conversions and show
the result. It is part of
http://www.vm.ibm.com/download/packages/descript.cgi?REXXG
For example XTOX 56 displays:
C2D(56)=13622 =X'3133363232'
C2X(56)=3536 =X'33353336'
D2C(56)=8 =X'38'
D2X(56)=38 =X'3338'
X2C(56)=V =X'56'
X2D(56)=86 =X'3836'
X2B(56)=01010110 =X'3031303130313130'
B2X(56)=impossible
2010/4/30 Bruce Roy <brucer...@hotmail.com <mailto:brucer...@hotmail.com>>
Try using the X2C REXX builtin function. For example,
String = X2c(PRK)
If the value of PRK will ever have a length different than 4 (which
seems to
be required by your logic), check the X2c documentation for the length
operand.
-----------------------------
From: The IBM z/VM Operating System [mailto:IBMVM@LISTSERV.UARK.EDU
<mailto:IBMVM@LISTSERV.UARK.EDU>] On
Behalf Of Horlick, Michael
Sent: Friday, April 30, 2010 9:37 AM
To: IBMVM@LISTSERV.UARK.EDU <mailto:IBMVM@LISTSERV.UARK.EDU>
Subject: How to work with hex in REXX
Greetings,
I have a character field for example 0001A735 (PRK)
I have record like this ‘DATA DATA YYYY’. I want to replace ‘YYYY’ with
x’0001A735’.
Tried :
String = "'"||PRK||"'x"
JCL.J = Overlay(String,Record,WORK,4)
Where work = position of ‘YYYY’ in record
Not working.
Mike Horlick
Conseiller
CGI Gestion Intégrée des Technologies
1350 Boul. René-Lévesque Ouest
Montréal, Qc, H3G 1T4
--
Kris Buelens,
IBM Belgium, VM customer support