Re: convert packed CHAR to unpacked DIGIT



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
.



Relevant Pages

  • Re: convert packed CHAR to unpacked DIGIT
    ... ssb wrote: ... > Input record has a field of size 5 bytes containing packed numbers. ... > this field is defined as CHARACTER. ... half-byte of the rightmost byte, if indeed the real field size is six ...
    (comp.lang.cobol)
  • convert packed CHAR to unpacked DIGIT
    ... Input record has a field of size 5 bytes containing packed numbers. ... this field is defined as CHARACTER. ... Any suggestions/help..? ... Prev by Date: ...
    (comp.lang.cobol)
  • Re: convert packed CHAR to unpacked DIGIT
    ... > Input record has a field of size 5 bytes containing packed numbers. ... > this field is defined as CHARACTER. ... Move WS-A to X ... End-Perform ...
    (comp.lang.cobol)
  • Re: Arabic cursive in Unicode
    ... For example, on the Mac, as you type an Arabic character, you see an isolated form or a final form. ... This means that the display software has to look at the context of the "logical character codes" and select the appropriate "presentation glyphs" every time the text has to be re-displayed. ... It would be up to the software whether to give the user the option of displaying the ligatures from the Presentation Forms-A list. ... I suspect that this kind of option would only be available in specialized Arabic-language input software. ...
    (sci.lang)
  • [PATCH] console UTF-8 fixes
    ... I send a patch to the UTF-8 part of the vt driver. ... If a certain character is not found in the glyph ... characters) is to simply display the glyph loaded in that position. ...
    (Linux-Kernel)