Max

This function is used to calculate the maximum for a list of elements such as dates, numeric values, and string values. It works on a list of elements that can be:
* Expressions.
* Arrays or sub-arrays of an array.
* Properties in an array of references.

Syntax

max(ELEMENT_LIST)

Examples

# Calculates the max for a list of totaled valuesMY_RATE=max(CURRENT_CURRENCY_RATE, AVERAGE_COMPOUND_RATE, LEGAL_RATE)# Is there a unique delivery date for a sales order?If max(MYORDER.LINES(1..maxtab(MYORDER.LINES)).DELIVERYDATE<>min(MYORDER.LINES(1..maxtab(MYORDER.LINES)).DELIVERYDATE)MESSAGE="We have to ship the order lines at different dates"ElseMESSAGE="All the lines can be delivered at the same date"Endif# Maximum and minimum on a matrix of values# We have NB_SALESREP sales representative in our department (NB_SALESREP<20)Local Decimal TURNOVER(1..12,1..20), BEST_TURNOVER, WORST_TURNOVERLocal Integer MONTH, SALESREP_ID# Fill the arrayFor MONTH=1 To 12For SALESREP_ID=1 To NB_SALESREPTURNOVER(MONTH,SALESREP_ID)=func GET_FIGURES(MONTH, SALESREP_ID)Next SALESREP_IDNext MONTH# Find out the best and the worst turnoverBEST_TURNOVER=max(TURNOVER(1..12,1..NB_SALESREP))WORST_TURNOVER=min(TURNOVER1..12,1..NB_SALESREP))

Comments

Decimal, integer, floating point and double variables may be mixed for a numerical maximum.

If one of the arguments in the function is an array variable without specifying index or range of indexes, all the variable elements are used. The specified index or range of indexes determines the elements to be considered.

If a range of indexes is given such that there is no element to consider, the result returned is the lowest possible value such as an empty string, null date, or lowest numeric value depending on the type of variable.

The type of result depends on the type of argument:

See also

sum, prd, avg, min.