|
Here's some pseudo code: Z-add the number to a zoned field that has a character overlay. Move the character field to an array. Use another array for the result. If the number is negative make the first cell in the result array a minus sign. Go through the source array. If the character is not blank, move it to the target array incrementing its index. Insert the decimal point at the proper point. (it should always come after the seventh character in the source array if it's a 9,2.) This could probably be made a little more elegant, but this is one approach. You could also do this with substringing and concatenation, but I tend to think of arrays first--it's a matter of taste. > -----Original Message----- > From: Jason Waugh [mailto:jwaugh@collectcorp.com] > Sent: Thursday, October 19, 2000 8:06 AM > To: RPG400-L@midrange.com > Subject: Beginner needs help w/ decimal field to text field > > > I have a decimal field... 9 digits, 2 decimals. I need to > move it into a character field of 14 characters, complete > with negative sign and decimal. I need it to be left > justified and padded with blanks. Examples: > > 9.32 (00000000932) should become '9.32 ' > -456.34 should become '-456.34 ' > > +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 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.