Minimum and Maximum

Jump to: Min
Jump to: Max

Min

The Min procedure is used to compare a list of two or more numeric values and return the lowest value.

lower-numeric-value Min(
  nCompValue1      30P 9    Const :
  nCompValue2      30P 9    Const :
  nCompValue3      30P 9    Const :
  ... repeat for additional compare values up to 16 times...
)

See also: InList

Parameters

nCompValue1 
[ input Pkd(30,9) const] Any numeric value may be specified (packed, zoned, binary, expression) that value is compared with each subsequent value of the procedure.
nCompValue2...n [ optional ]
[ input Pkd(30,9) const] Any numeric value may be specified (packed, zoned, binary, expression) that value is compared with each subsequent value of the procedure.

The procedure compares each parameter and returns the lowest value on the list of specified values.

Return Value

The procedure compares each parameter and returns the lowest value on the list of specified values.

Example:

.....CSRn01..............OpCode(ex)Extended-factor2+++++++++++++++++++++++
     C                   eval      i = min(7 : 8.5 : nLimit/2 : nCount )

In this example, the lowest value specified on the parameter list for the MIN() procedure is returned. If either nCount or nLimit/2 are less than 7, their value will be returned, otherwise the number 7 (the first parameter) is returned.

Typically, all values specified will be of the same data type and lengths

 


Max

The Max procedure is used to compare a list of two or more numeric values and return the largest value.

highest-numeric-value Max(
  nCompValue1      30P 9    Const :
  nCompValue2      30P 9    Const :
  nCompValue3      30P 9    Const :
  ... repeat for additional compare values up to 16 times...
)

See also: InList

Parameters

nCompValue1 
[ input Pkd(30,9) const] Any numeric value may be specified (packed, zoned, binary, expression) that value is compared with each subsequent value of the procedure.
nCompValue2...n [ optional ]
[ input Pkd(30,9) const] Any numeric value may be specified (packed, zoned, binary, expression) that value is compared with each subsequent value of the procedure.

Return Value

The procedure compares each parameter and returns the value on the list with the highest numeric value.

Example:

.....CSRn01..............OpCode(ex)Extended-factor2++++++++++++++++++++++++++
     C                   eval      i = max(7 : 8.5 : nLimit/2 : nCount )
     C                   eval      BestMonth = max(Jan:Feb:Mar:Apr:May:Jun:
     C                   eval                      Jul:Aug:Sep:Oct:Nov:Dec)
 
 

In this example, the highest value specified on the parameter list for the MAX() procedure is returned. If either nCount or nLimit/2 are greater than 8.5, their value will be returned, otherwise the number 8.5 (the second parameter) is returned. Typically, all values specified will be of the same data type and lengths.

The second line finds the highest monthly sales figure and stores it in the BestMonth field.