Return to the RPG Tips
BIF to trim leading 0's from a character field - Technique 2
Here goes. I hope it comes through ok. This is old source written for V3R3 and could probably updated...
I usually call it like this:
#ZChar(field:%size(field))
*//////////////////////////////////////////////////////////////* * (#ZChar) Zero Supress A Character Field * * * * This procedure will replace all leading zeros with blanks. * *//////////////////////////////////////////////////////////////* P #ZChar B EXPORT *--------------------------------------------------------------* D #ZChar PI 256 D text 256 VALUE D size 3 0 VALUE * D textout S 256 D i S 3 0 *--------------------------------------------------------------* C 1 do size i * C if (%subst(text:i:1) = ' ') C ITER C endif * C if (%subst(text:i:1) = '0') C eval %subst(text:i:1) = ' ' C ITER C endif * C LEAVE C enddo * C eval textout = %trim(%subst(text:1:size)) * C if (textout = ' ') C eval textout = '0' C endif * C RETURN textout *--------------------------------------------------------------* P #ZChar E
[report a broken link by clicking here]