Page 1 of 1

### How to read HEX file and convert it into decimal in REXX.

Posted: Mon Jan 18, 2010 2:19 pm
Hi,

I have a file in which data is in the Hex format as below.

?..%.?..........?......@...

And when i give a command 'HEX ON' then the data in the file is converted as below.

?..%.?..........?......@...
A00608020002013040000007300
A93C9C3C200C00C953C05C2C4CC

Now i want to read the file in the HEX format and want to bring some data in to some variables.

Eg: Varable A must be equal to 09036C.

Posted: Mon Jan 18, 2010 3:44 pm
lookat 4.3.14 C2X (Character to Hexadecimal)

here is a REXX (or routine) that you can CALL:

Code: Select all

``````/* REXX  CONVERT PACKED DECIMAL TO NUMBER */
PARSE ARG PACK_NUM
HEX_NUM  = C2X&#40;PACK_NUM&#41;
SIGN  = RIGHT&#40;HEX_NUM,1&#41;
NUMBER  = LEFT&#40;HEX_NUM,LENGTH&#40;HEX_NUM&#41;-1&#41;
IF SIGN = 'D' THEN
RETURN '-'| |NUMBER
ELSE
RETURN NUMBER
``````

Posted: Mon Jan 18, 2010 4:35 pm
Thanks a lot ..

it worked ... but can you explan me the code.

Posted: Mon Jan 18, 2010 4:38 pm
but can you explan me the code.(sic)
no,

use
TRACE ?R
to follow the flow and refer to the manual for info on instructions.

Posted: Mon Jan 18, 2010 4:41 pm
Thanks a lot.

### REXX CONVERT PACKED DECIMAL routine is great!

Posted: Tue Nov 02, 2010 1:05 am
hey Dick... your solution works like a champ... thanks very much!
here is a REXX (or routine) that you can CALL:
Code:

/* REXX CONVERT PACKED DECIMAL TO NUMBER */
PARSE ARG PACK_NUM
HEX_NUM = C2X(PACK_NUM)
SIGN = RIGHT(HEX_NUM,1)
NUMBER = LEFT(HEX_NUM,LENGTH(HEX_NUM)-1)
IF SIGN = 'D' THEN
RETURN '-'| |NUMBER
ELSE
RETURN NUMBER

Posted: Tue Nov 02, 2010 3:36 am
actually the routine came from someone else, and can't remember who I stole it from,
but here is a list of Sites that you should visit if you want to add to your tools:

Doug Nadel's site a must see
lionel B dyck's site visit this also
Rexx Examples old but useful
Dave's MVS Freeware - Rexx
and the american programmer has a lot of useful info