On Nov 21, 2005, at 2:41 PM, John Krew wrote:

Aside from writing and CALLing a trivial assembler routine, is there any way to display the
hexadecimal content of a field in a COBOL program using COBOL syntax?

John Krew


Easily:

      01  Misc-Storage.
        02  I             Pic S9(8) Comp-5.
        02  J             Pic S9(8) Comp-5.
        02  CH            Pic S9(4) Comp-5.
        02  redefines CH.
          03              Pic X.
          03 CH-X         Pic X.
        02  NB            Pic S9(4) Comp-5.
        02  HEX           Pic X(16) Value '0123456789abcdef'.

       *
       * Routine assumes var V and length V-Len are defined and
       * loaded with the data you wish to dump.
       *
       * Assumes var H and is twice the length of V.
       *
        Dump-Hex-String.

             Move 0 to CH
             Move 1 to J
             Perform varying I from 1 by 1
               until (I > V-Len)
        
                Move V(I:1) to CH-X
                Divide CH by 16 giving CH remainder NB
                Move HEX(CH:1) to H(J    :1)
                Move HEX(NB:1) to H(J + 1:1)
                Compute J = J + 2

             End-Perform

             Display H
             .

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to