-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
john gilmore said the following on 11/21/2005 09:02 PM: | It's not yet at all easy to do this in COBOL; Sure it is. Depends on anyone's definition of "easy", of course. One can always use the algorithms one would use when doing the same byte by byte, without using fancy things like packed decimal and inspect, like John does (His solution will fail on a Windows platform, BTW) | but it will be possible, | even in a certain sense easy, after someone implements the new standard, | which makes bit strings available. | | To make clear what is involved here is a PL/I procedure: which is, of course, easy ... | ptrhexF: procedure(ptr) | returns(character(8)) | reorder; <snipped, otherwise this post gets rejected again> but the OP asked for COBOL, didn't he? A COBOL version: ~ CBL SSRANGE TEST ~ Identification Division. ~ Program-Id. X2C IS INITIAL. ~ Data Division. ~ Working-Storage Section. ~ 01 Hex-Table PIC X(16) VALUE '0123456789ABCDEF'. ~ 01 Out-Text PIC X(512) VALUE SPACES. ~ 01 Char-Pos PIC S9(4) BINARY. ~ 01 Out-Pos1 PIC S9(4) BINARY. ~ 01 Out-Pos2 PIC S9(4) BINARY. ~ 01 Num-Data PIC 9(4) BINARY VALUE ZERO. ~ 01 REDEFINES Num-Data. ~ 02 Hex-Byte PIC X. ~ 02 FILLER PIC X. ~ 01 High-Nibble PIC 9(4) BINARY. ~ 01 Low-Nibble PIC 9(4) BINARY. ~ Linkage Section. ~ * hex string to be translated ~ 01 Text-in-string. ~ 05 Text-in-chars PIC X OCCURS 1 to 255 TIMES ~ DEPENDING ON Text-in-length. ~ 01 Text-in-length PIC 9(9) BINARY. ~ * area to received translated character string ~ 01 Text-out-length PIC 9(9) BINARY. ~ 01 Text-out-string. ~ 05 Text-out-chars PIC X OCCURS 1 to 510 TIMES ~ DEPENDING ON Text-out-length. ~ Procedure Division USING Text-in-string ~ Text-in-length ~ Text-out-string ~ Text-out-length. ~ X2C-ENTRY. ~ MOVE SPACES TO Out-Text ~ MOVE ZEROES TO Num-Data ~ PERFORM VARYING Char-Pos ~ FROM 1 ~ BY 1 ~ UNTIL Char-Pos = Text-in-length ~ MOVE Text-in-string(Char-Pos:1) TO Hex-Byte ~ DIVIDE Num-Data BY 16 GIVING High-Nibble ~ REMAINDER Low-Nibble ~ ADD 1 TO High-Nibble Low-Nibble ~ COMPUTE Out-Pos1 = 2 * Char-Pos - 1 ~ COMPUTE Out-Pos2 = Out-Pos1 + 1 ~ MOVE Hex-Table(High-Nibble:1) TO Out-Text(Out-Pos1:1) ~ MOVE Hex-Table(Low-Nibble:1) TO Out-Text(Out-Pos2:1) ~ END-PERFORM ~ MOVE Out-Text to Text-out-string ~ GOBACK ~ . - -- ~ With kind Regards |\ _,,,---,,_ ~ ZZZzz /,`.-'`' -. ;-;;, ~ Volker Bandke |,4- ) )-,_. ,\ ( `'-' ~ (BSP GmbH) '---''(_/--' `-'\_) ~ HELP!!!! I'm being held prisoner in /usr/games/lib! ~ (Another Wisdom from my fortune cookie jar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDgkLXHm2sbKEAXTARAqC4AJ0YVXC95WDEvpWFzJwD4Bpqf5tOGgCghbD2 85sT7QkcBBDJSRcygbftmak= =gLAq -----END PGP SIGNATURE----- ---------------------------------------------------------------------- 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

