× 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.



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


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.