MAX

Contents


max allows you to find the maximum of a series of numeric, alphanumeric, or date variables.

 

Syntax

   max (exprg_list)

 

Parameters

Element

Description

Remarks

exprg_list

List of generalized_expressions separated by a comma (,)

All expressions that must be the same type

 

Examples

   # Maximum of several numeric expressions;
   # this program displays 8.66
    MAXIMUM = max(pi, exp(1), log(24), sqr(2)*2, sin(0.58), 5*sqr(3))
    MAXIMUM = ar2(MAXIMUM)
    Infbox num$(MAXIMUM)
   # Maximum of several strings
    MOTS(40)(50) Char   :# Definition of 50 strings of 40 characters
    Gosub LIRE_MOTS:     # Loading of the MOTS variable
    DERNIER_MOT = max(MOTS)
   # Check that no date comes after FIN_PERIODE; the dates
   # were entered in a scrolling table for which the variable at the bottom of
   # the table is VARBAS
    If max([M]DATES(0..[M]VARBAS-1) >= FIN_PERIODE
       Errbox "Date outside of the interval!"
    Endif

 

Description and Comments

max calculates the maximum of a number globally of the same type (alphanumeric, date, or numeric) - regardless of the variables or expressions.

For a numeric maximum, you may mix expressions and variables of the Integer, Shortint, Libelle, and Decimal types. The comparison in the sense of the strings is used for an alphanumeric maximum.
The type of result depends on the type of parameter. The following should be determined:

·         string maximum:         the result is of the Char type

·         date maximum:              the result is the Date type.

·         numeric maximum: the result is Integer or Decimal (depending on the maximum value type).

If one of the function's parameters is a variable that was sized with no index or index range precision, then all of the variable's elements are used. The precision of an index or of an index range determines the elements to be considered.

If you give an index range in such a way that no element should be considered in the list, e.g., max(VARIABLE(1..0)), the result returned is the lowest value, depending on the variable type, i.e., empty string for strings; -2^15 for short integers; -2^31 for long integers; about -10^80 for decimals and doubles; about -10^38 for floating numbers; 0 for descriptions; and, [0/0/0] for dates, respectively.

 

Associated Errors

Error

Description

ERMODE (10)

The indexes given are not numeric.

ERINDI (8)

Range Error for Indexes

ERDOM (50)

The parameters are not the same type.

ERDIM (55)

Too many dimensions given

 

Associated Keywords

MIN - SUM - PRD - AVG - VAR - UNI - FIND


CONTENTS


Copyright © Sage 1999 - 2007