|
Buck Calabro wrote:
Hans said:Well, if %EDITW does what you want, then why not just use that? But if you want to avoid %EDITW, then you can always try: %xlate(' ':'0':%editc(num:'3'))Which requires a V5 OS/400 release. The request didn't mention them, but %xlate doesn't handle negative numbers. If, for instance the input number was -12.34, you would probably use the L edit code, which would result in 00012.34- If you use an L edit code on a positive number like 12.34 you would get 00012.340, because of the trailing space where the sign would go. Of course you could wrap that up in a test and use edit code 3 for positive numbers and L for negative numbers, but why go through that?
Well, note that I specified edit code 3 in my example, which drops
the sign. If a leading sign is still needed, some extra step would
of course be needed. If you wanted, you could still do it all in
one single expression, such as:
signs(%int(number<0)+1)+%xlate(' ':'0':%editc(number:'3'))
where SIGNS is a 2 element character varying array initialized with
the values '' and '-'.
(OK, that needs V5R2. In V5R1, just use your favorite method to
convert character to numeric instead of %INT.)
Hans' comment about %editw makes sense to me.
I understand Seth's relucatance to use %EDITW. If the length of the database field changes, he would have to change all his edit words. Cheers! Hans
This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.