ifGreaterThan

The ifGreaterThan NSM predefined function returns the string specified in onTrue if param1 is greater than param2. Otherwise, the function returns the string specified in onFalse.

Syntax

ifGreaterThan(param1,param2,onTrue,onFalse)

Parameters

param1
Specifies a number.
param2
Specifies a number.
onTrue
Specifies a string that is returned if param1 is greater than param2.
onFalse
Specifies a string that is returned if param1 is not greater than param2.

Description

The ifGreaterThan NSM predefined function compares the strings specified in param1 and param2. The function returns the string specified in onTrue if param1 is greater than param2. Otherwise, the function returns the string specified in onFalse.

Returns

This function returns the string specified in onTrue if param1 is greater than param2. Otherwise, the function returns the string specified in onFalse.

Examples

ifGreaterThan("45.5","45.0","t","f") returns "t"
ifGreaterThan("3455.000","3455","true","false") returns "false"
ifGreaterThan("6","7","yes","no") returns "no"
ifGreaterThan("four","five","t","f") /* ERROR is thrown here*/

The following descriptions explain how the ifGreaterThan function operates on the parameters:

  • In the first example, the ifGreaterThan NSM predefined function compares the string specified in param1 ("45.5") with the string specified in param2 ("45.0"). Because the string specified in param1 is greater than the string specified in param2, the ifGreaterThan function returns the string "t" that is specified in onTrue.
  • In the second example, the ifGreaterThan NSM predefined function compares the string specified in param1 ("3455.000") with the string specified in param2 ("3455"). Because string specified in param1 is not greater than the string specified in param2, the ifGreaterThan function returns the string "false" that is specified in onFalse.
  • In the third example, the ifGreaterThan NSM predefined function compares the string specified in param1 ("6") with the string specified in param2 ("7"). Because string specified in param1 is not greater than the string specified in param2, the ifGreaterThan function returns "no" that is specified in onFalse.
  • In the fourth example, the ifGreaterThan NSM predefined function compares the string specified in param1 ("four") with the string specified in param2 ("five"). The param1 and param2 parameters require numbers. Because the string value does not resolve to a number, ifGreaterThan returns an error.

As can be seen in the examples, the ifGreaterThan function provides flexibility in specifying the strings to return in the onTrue and onFalse parameters.