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



Hi Joe,

I agree that it makes sense to put them as parms on the conversions, but it seems like less of a change to the compiler to change %dec, %dech and then use them in the conversions, e.g.

    formatted Value = %CHAR( %DEC( myNumericExpression: wDigits: wDecimals) )

    formattedValue = %EDITC( %DEC( myNumericExpression: wDigits: wDecimals) : 'L' : *CURSYM);

then you wouldn't need a place holder:

    formattedValue = %EDITC( %DEC( myNumericExpression: wDigits: wDecimals): 'L');

Otoh, if they're on the conversions (and let's not forget %EDITW), then maybe there's less of a concern about intermediate results.

--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx <mailto:petercdow@xxxxxxxxx>
pdow@xxxxxxxxxxxxxx <mailto:pdow@xxxxxxxxxxxxxx>

/
On 3/7/2020 7:45 AM, Joe Pluta wrote:
That makes a lot of sense.  And in that case, maybe it would be better to put the precision as optional parameters on the conversions?

    formattedValue = %CHAR( myNumericExpression: wDigits: wDecimals);

It might take a little more work to shoehorn it into %editc since there's already an optional parameter for currency, but something like this:

    formattedValue = %EDITC( myNumericExpression: 'L': *CURSYM: wDigits: wDecimals);

And if you didn't want a currency symbol, just put the placeholder *PREC:

    formattedValue = %EDITC( myNumericExpression: 'L': *PREC: wDigits: wDecimals);

Because basically you're just trying to resize the field for formatting, so why not do it right in the formatting?




On 3/6/2020 2:27 PM, Barbara Morris wrote:
I was going to say it would be impossible for RPG to support variables for the precision and scale parameters for %DEC and %DECH because RPG is a compiled language, and it has to know the precision of numeric operands.

But as I was writing, I realized it would actually be possible as long as the result of the %DEC or %DECH wasn't being used in a numeric calculation, or anything else where the precision and scale were needed at compile time.

On 2020-03-06 2:55 p.m., Jon Paris wrote:
So write up an RFE asking for that enhancement.

I suspect many would vote for it.


On Mar 6, 2020, at 12:39 PM, dlclark@xxxxxxxxxxxxxxxx wrote:
...
        Well, I would rather have seen IBM create %DEC and %DECH to accept
true variable data for the precision and scale parameters. ;-)





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.