When communicating with ASCII computers through the async workstation controller of our AS/400, I sometimes need to convert a decimal number to its equivalent hexadecimal value. I wrote a short RPG program (HEX001RG) to handle the conversion, as illustrated in 2.
When communicating with ASCII computers through the async workstation controller of our AS/400, I sometimes need to convert a decimal number to its equivalent hexadecimal value. I wrote a short RPG program (HEX001RG) to handle the conversion, as illustrated in Figure 2.
The program accepts a 15-digit, right-justified decimal integer through a character variable. It returns the equivalent hexadecimal value in another 15- character variable. This program is meant to be called from another program that requires the conversion. For example, you could write a display file and program to accept a decimal integer and display the converted value.
Decimal-to-Hex Conversion Program
Figure 2 Decimal-to-Hex Conversion Program HEX001RG
*=============================================================== * To compile: * * CRTRPGPGM PGM(XXX/HEX001RG) SRCFILE(XXX/QRPGSRC) * *=============================================================== *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 E HX 15 15 1 * C *ENTRY PLIST C PARM PDEC 15 C PARM $HEX * C MOVE PDEC $DEC 150 C MOVE *BLANKS $HEX C $DEC IFNE 0 C EXSR CALC C EXSR SWAP C ELSE C MOVE $DEC $HEX C ENDIF C MOVE *ON *INLR ***************************************************************** C CALC BEGSR * C $DEC DOWGE16 C $DEC DIV 16 $DEC C MVR X C X IFGT 0 C $HEX CAT HX,X:0 $HEX C ELSE C $HEX CAT '0':0 $HEX C ENDIF C ENDDO * C Z-ADD$DEC X 30 C $HEX CAT HX,X:0 $HEX 15 P C ENDSR ***************************************************************** C SWAP BEGSR * C ' ' CHEKR$HEX Z 30 C Z DOWGT0 C SUBST$HEX:Z $CHR1 1 P C $HLD CAT $CHR1:0 $HLD 15 P C SUB 1 Z C ENDDO * C MOVE *BLANKS $HEX C ' ' CHEKR$HLD Z C 15 SUB Z Z * C Z DOWGT0 C $HEX CAT '0':0 $HEX C SUB 1 Z C ENDDO * C $HEX CAT $HLD:0 $HEX C ENDSR *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ** HX 123456789ABCDEF
Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.
IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn:
LATEST COMMENTS
MC Press Online