xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Max()

Returns the larger value of two Numerics or Dates.

Syntax

Max( <nNum1> , <nNum2>  ) --> nLargerNumber
Max( <dDate1>, <dDate2> ) --> dLargerDate

Arguments

<nNum1> and <nNum2>
Two numeric values to be compared.
<nDate1> and <nDate2>
Two Date values to be compared.

Return

The function returns the larger value of the two arguments.

Description

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().

Info

See also:Min()
Category: Numeric functions , Date and time
Source:rtl\minmax.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe