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

The SQL scalar functions MIN() and MAX() can also be used within RPG to find
the highest or lowest value from a list of values:

Example:
Exec SQL Set :MyMinVal = Min(1, -17, 35, 4, -2, 0);
Exec SQL Set :MyMinDate = Min(Date('2009-01-03'), Date('2009-02-18'),
:Date('2008-12-31'));
Exec SQL Set :MyMaxChar = Max('ABC', 'A', ' XY', 'A34579');
Exec SQL Set :MyMaxVal = Max(:HstVar1, :HstVar2, :HostVar3, :HostVar4);

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von Carel Teijgeler
Gesendet: Wednesday, 22. April 2009 17:01
An: rpg400-l@xxxxxxxxxxxx
Betreff: Re: Function to find the greatest or smallest value

If you have not searched the manuals (i.e. the Index of the RPG Reference),
you should have first, but no, you have to write your own.

If the values come from a PF (table), use SQL and the MIN/MAX-functions.

With regards,
Carel Teijgeler

*********** REPLY SEPARATOR ***********

On 22-4-2009 at 16:21 David FOXWELL wrote:

Given 2 or more values, is there a BIF or something in RPG that will
return the highest of those values?



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.