Return to Mainframe Utilities Page

## Module

PROC 2 HEXNUM1 HEXNUM2 /**** SET MESSAGE DISPLAY ON/OFF BASED ON THE DEBUG SWITCH ***/ ISPEXEC VGET (DBGSWTCH) PROFILE IF &DBGSWTCH = &STR(ON) THEN CONTROL MSG LIST CONLIST SYMLIST NOFLUSH ELSE CONTROL NOMSG NOLIST NOFLUSH NOPROMPT IF &HEXNUM1 = &STR(HELP) THEN GOTO HELPSEC SET HLEN1 = &LENGTH(&HEXNUM1) IF &HLEN1 > 8 THEN GOTO END1 SET COUNT = 1 SET SLEN = &HLEN1 - 1 SET SNUM1 = 0 DO WHILE &COUNT LE &HLEN1 SET HCHAR = &SUBSTR(&COUNT,&HEXNUM1) IF &HCHAR = A THEN SET HCHAR = 10 IF &HCHAR = B THEN SET HCHAR = 11 IF &HCHAR = C THEN SET HCHAR = 12 IF &HCHAR = D THEN SET HCHAR = 13 IF &HCHAR = E THEN SET HCHAR = 14 IF &HCHAR = F THEN SET HCHAR = 15 SET SNUM1 = &SNUM1 + (&HCHAR * (16 ** &SLEN)) SET COUNT = &COUNT + 1 SET SLEN = &SLEN - 1 END /* SET HLEN2 = &LENGTH(&HEXNUM2) IF &HLEN2 > 8 THEN GOTO END2 SET COUNT = 1 SET SLEN = &HLEN2 - 1 SET SNUM2 = 0 DO WHILE &COUNT LE &HLEN2 SET HCHAR = &SUBSTR(&COUNT,&HEXNUM2) IF &HCHAR = A THEN SET HCHAR = 10 IF &HCHAR = B THEN SET HCHAR = 11 IF &HCHAR = C THEN SET HCHAR = 12 IF &HCHAR = D THEN SET HCHAR = 13 IF &HCHAR = E THEN SET HCHAR = 14 IF &HCHAR = F THEN SET HCHAR = 15 SET SNUM2 = &SNUM2 + (&HCHAR * (16 ** &SLEN)) SET COUNT = &COUNT + 1 SET SLEN = &SLEN - 1 END /* SET SNUM2 = &SNUM2 + &SNUM1 SET ANUM = &SNUM2 SET HLEN3 = &LENGTH(&SNUM2) SET COUNT = &HLEN3 /* DO WHILE &ANUM NE 0 SET BNUM = &ANUM / 16 SET CNUM = &BNUM * 16 SET RNUM = &ANUM - &CNUM SET ANUM = &BNUM IF &RNUM = 10 THEN SET RNUM = A IF &RNUM = 11 THEN SET RNUM = B IF &RNUM = 12 THEN SET RNUM = C IF &RNUM = 13 THEN SET RNUM = D IF &RNUM = 14 THEN SET RNUM = E IF &RNUM = 15 THEN SET RNUM = F IF &COUNT = 1 THEN SET &HC1 = &RNUM IF &COUNT = 2 THEN SET &HC2 = &RNUM IF &COUNT = 3 THEN SET &HC3 = &RNUM IF &COUNT = 4 THEN SET &HC4 = &RNUM IF &COUNT = 5 THEN SET &HC5 = &RNUM IF &COUNT = 6 THEN SET &HC6 = &RNUM IF &COUNT = 7 THEN SET &HC7 = &RNUM IF &COUNT = 8 THEN SET &HC8 = &RNUM SET COUNT = &COUNT - 1 END /* SET HNUM = &STR(&HC1&HC2&HC3&HC4&HC5&HC6&HC7&HC8) /* SET ZEDLMSG = + &STR(HEX (&HEXNUM1) + HEX (&HEXNUM2) = DECIMAL (&SNUM2) HEX (&HNUM)) ISPEXEC SETMSG MSG(UTLZ000) EXIT END1: + SET ZEDLMSG = + &STR("HEXADD" CANNOT HANDLE EITHER HEX NUMBER BEING GREATER THAN 8 + DIGITS) ISPEXEC SETMSG MSG(UTLZ001) EXIT END2: + SET ZEDLMSG = + &STR("HEXADD" CANNOT HANDLE EITHER HEX NUMBER BEING GREATER THAN 8 + DIGITS) ISPEXEC SETMSG MSG(UTLZ001) EXIT HELPSEC: + 04470000 CLEAR 04470000 WRITE *** HELP FOR CLIST HEXADD *** 04470000 WRITE 04470000 WRITE NO HELP WRITTEN AT THIS TIME 04470000 WRITE 04470000 WRITE *** END OF HELP *** NO PROCESSING PERFORMED *** 04470000 EXIT 04470000

## Documentation

This CLIST takes 2 hexadecimal numbers as input, adds them together and displays the result in hexadecimal and decimal format. An example is as follows : COMMAND ===> HEXADD 34FE 557834 The resulting message would be : HEX (34FF) + HEX (557834) = DECIMAL (5614899) HEX (55AD33) Neither input number can be greater than 8 digits in length.