× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Since you are using edit code 3... wouldn't %Char be the better option for
you. %Char trims the number but doesn't put in any commas.


--

Michael Schutte
Admin Professional



Try Bob Evans GRILLING SAUSAGE! This summerâs hottest destination is your
own backyard with Bob Evans Brats and Italian Sausage! For tasty recipes
using Bob Evans grilling sausage, visit http://www.BobEvans.com/Recipes





John Rusling
<jrusling@johnson
brothers.com> To
Sent by: "'rpg400-l@xxxxxxxxxxxx'"
rpg400-l-bounces@ <rpg400-l@xxxxxxxxxxxx>
midrange.com cc

Subject
07/02/2009 10:09 One function to Trim and Edit a
AM number.


Please respond to
RPG programming
on the IBM i /
System i
<rpg400-l@midrang
e.com>






I find I'm constantly using %trim(%editc(Cust#:'3')) for
messages, logs, etc.

I got sick of having to use 2 bifs to do this.

So I made tred() and it works great for numbers with
zero decimal places.

Without tred -

msg_Send('Customer ' + %trim(%editc(sfCust#:'3'))
+ ' not found.');

With tred (optional editcode not passed) -

msg_Send('Customer ' + tred(sfCust#)
+ ' not found.');

I find I'm using this in a ton of places, but, it doesn't
handle decimal places, so --

I made another one, tred2() to do the same thing
but for 2 decimal places.

Anyone got a better and/or cleaner scheme to do this,
as far as handling 1,2,3 or 4 decimal places?
(1 function to handle all decimal place variations)

Improvement suggestions?

Anyway, if not, and you find this useful, then great!

John B.





//--------------------------------------------------------------------
// Trim & Edit a number at the same time, 0 decimal places.

//--------------------------------------------------------------------
d tred...
d pr 20 varying
d pNbr 15p 0 value
d pEditCode 1 const options(*nopass)



//===============================================================
p tred...
p b export
d pi 20 varying
d pNbr 15p 0 value
d pEditCode 1 const options(*nopass)

// Trim & Edit a number at the same time.
//===============================================================
d editcode s 1
d rtnval s 20 varying

/free

if %parms > 1;
editcode = pEditCode;
else;
editcode = '3';
endif;

select;
when editcode = '1';
rtnval = %trim(%editc(pNbr:'1'));
when editcode = '2';
rtnval = %trim(%editc(pNbr:'2'));
when editcode = '3';
rtnval = %trim(%editc(pNbr:'3'));
when editcode = '4';
rtnval = %trim(%editc(pNbr:'4'));

when editcode = 'J';
rtnval = %trim(%editc(pNbr:'J'));
when editcode = 'K';
rtnval = %trim(%editc(pNbr:'K'));
when editcode = 'L';
rtnval = %trim(%editc(pNbr:'L'));
when editcode = 'M';
rtnval = %trim(%editc(pNbr:'M'));

when editcode = 'X';
rtnval = %trim(%editc(pNbr:'X'));
when editcode = 'Z';
rtnval = %trim(%editc(pNbr:'Z'));

other;
rtnval = %trim(%editc(pNbr:'Z'));
endsl;

return rtnval;

/end-free
p e

--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.