Re: convert packed CHAR to unpacked DIGIT
- From: Louis Krupp <lkrupp@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 16 Apr 2005 03:05:43 -0600
ssb wrote:
Hi,
Input record has a field of size 5 bytes containing packed numbers. But this field is defined as CHARACTER.
E.g. WS-A PIC X(5) '1212343455'
My task is to display '1212343455' on a report. Obviously, it requires converting packed to unpacked numbers.
I tried doing something like this:
MOVE X(5) TO 9(9) COMP-3. REDEFINE 9(9) COMP-3 AS 9(10)
Any suggestions/help..? Thanks.
If your compiler supports reference modification and the ORD intrinsic, you could try stepping through the input field one character at a time, using ORD to find its binary value, dividing that value by 16, and using the dividend and remainder respectively to index into a table of hexadecimal characters (0123456789ABCDEF), and moving the results into the output record.
Louis .
- References:
- convert packed CHAR to unpacked DIGIT
- From: ssb
- convert packed CHAR to unpacked DIGIT
- Prev by Date: Re: Editors
- Next by Date: Re: OT - "lie" vs "error"
- Previous by thread: Re: convert packed CHAR to unpacked DIGIT
- Next by thread: Re: convert packed CHAR to unpacked DIGIT
- Index(es):
Relevant Pages
|