Untested code (but I can't see why it wouldn't work:
P @max B Export
D PI 30P 9
D p1 30P 9 Const
D p2 30P 9 Const
D p3 30P 9 Const Options(*Nopass)
D p4 30P 9 Const Options(*Nopass)
D p5 30P 9 Const Options(*Nopass)
*---------------------------------------------------------------------
D out S 30P 9
*---------------------------------------------------------------------
/free
out = p1;
if p2 > out;
out = p2;
endif;
if %parms > 2;
if p3 > out;
out = p3;
endif;
if %parms > 3;
if p4 > out;
out = p4;
endif;
if %parms > 4;
if p5 > out;
out = p5;
endif;
endif;
endif;
endif;
return out;
begsr *pssr;
return 0;
endsr;
/end-free
This allows up to 5 parameters, so you can use it like this:
myvar = @max( var1 : var2 : var3 );
Almost the exact same code (with > replaced with <) can be used for a @min
function, obviously.
Put it into a module and then bind it into a service program - I have one
with generic functions like this, which is in a 'global' binding directory
so it can be bound to every program that needs it easily.
Rory
As an Amazon Associate we earn from qualifying purchases.
This thread ...
AW: Function to find the greatest or smallest value, (continued)
This mailing list archive is Copyright 1997-2026 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.