xHarbour Reference Documentation > Function Reference |
Returns the larger value of two Numerics or Dates.
Max( <nNum1> , <nNum2> ) --> nLargerNumber Max( <dDate1>, <dDate2> ) --> dLargerDate
The function returns the larger value of the two arguments.
The function compares two numeric or two Date values and returns the larger value of both. Max() is used to normalize values against a limit. The inverse function is Min().
See also: | Min() |
Category: | Numeric functions , Date and time |
Source: | rtl\minmax.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example uses Max() to identify the maximum length of a string within // a set of character strings for formatted console output PROCEDURE Main LOCAL aLabel := { "Day", "Hour", "Minutes", "Seconds" } LOCAL dDate := Date() LOCAL cTime := Time() LOCAL nPad := 0 AEval( aLabel, {|c| nPad := Max( nPad, Len(c) ) } ) ? PadL( aLabel[1], nPad ), dDate ? PadL( aLabel[2], nPad ), SubStr( cTime, 1, 2 ) ? PadL( aLabel[3], nPad ), SubStr( cTime, 4, 2 ) ? PadL( aLabel[4], nPad ), SubStr( cTime, 7, 2 ) RETURN
http://www.xHarbour.com