Return to the RPG Tips
Example of a program that auto-discriminates between packed and zoned numeric parameters
** Example of a program that auto-discriminates between ** packed and zoned numeric parameters. ** D p_packed1 S * INZ(*NULL) D p_packed2 S * INZ(*NULL) D Packed1 S 7P 0 based(p_packed1) D Packed2 S 7P 0 based(p_packed2) D p_zoned1 S * INZ(*NULL) D p_zoned2 S * INZ(*NULL) D Zoned1 S 7S 0 based(p_zoned1) D Zoned2 S 7S 0 based(p_zoned2) D DS D E_Val 1 2U 0 INZ(0) D C_Val 2 2A c *entry plist c parm parm1 1 c parm parm2 2 C* if the EBCDIC value of the first byte in parm1 C* is F0 or higher, it must be zoned: C* c eval C_Val = parm1 c if E_Val > 239 c eval p_zoned1 = %addr(parm1) c else c eval p_packed1 = %addr(parm1) c endif C* if the EBCDIC value of the first byte in parm2 C* is F0 or higher, it must be zoned: C* c eval C_Val = parm2 c if E_Val > 239 c eval p_zoned2 = %addr(parm2) c else c eval p_packed2 = %addr(parm2) c endif C* C* Example of how to know which variable to use, C* In this example, we're just displaying the values C* of parm1 & parm2: C* c if p_zoned1 = *NULL c 'Parm1' dsply packed1 c else c 'Parm1' dsply zoned1 c endif c if p_zoned2 = *NULL c 'Parm2' dsply packed2 c else c 'Parm2' dsply zoned2 c endif c eval *inlr = *on c return
[report a broken link by clicking here]