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



A couple of options.

One, do they REALLY want truncation? If not, you might consider using a max value. Define a field C_MAX as LIKE(FieldA) inz(*HIVAL). Then if FieldB > C_MAX then FieldA = C_MAX else FieldA = FieldB.

But if you don't like THAT [which I actually don't - it's the one reason I would really like a ternary operator in RPG like in Java: FieldA = (FieldB>C_MAX ? C_MAX : FieldB)], then how about this:

FieldA = truncate(FieldB);

Write your truncate procedure and you can even use fixed format code in it - hide it at the bottom and nobody will see!

BTW, if you want pretty free-form code, why are you using Eval? Just wondering...

Joe


FieldA is defined as 29.4 and FieldB is defined as 9.0. The following
calculation bombs on "Receiver value too small to hold the result."

Eval FieldB = FieldA;

I know that I can switch back into fixed format and use:
Z-ADD FIeldA FieldB

and the value of FieldB will contain a truncated value if FieldA is too
large to fit in FieldB. However, is there a way to accomplish this in
free-form RPG?

I know that this sounds stupid, and please do NOT ask me why I need to do
this.

I was told that if the value won't fit, truncate it, and I just don't want
to junk up my pretty free-form program with fixed-form code.

- sjl




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.