ifEquals

The ifEquals NSM predefined function returns the string specified in onTrue if param1 equals param2. Otherwise, the function returns the string specified in onFalse.

Syntax

ifEquals(param1,param2,onTrue,onFalse)

Parameters

param1
Specifies a string or a number.
param2
Specifies a string or a number.
onTrue
Specifies a string that is returned if param1 equals param2.
onFalse
Specifies a string that is returned if param1 is not equal to param2.

Description

The ifEquals NSM predefined function compares the strings specified in param1 and param2. The function returns the string specified in onTrue if param1 equals param2. Otherwise, the function returns the string specified in onFalse.

Returns

This function returns the string specified in onTrue if param1 equals param2. Otherwise, the function returns the string specified in onFalse.

Examples

ifEquals("345.000","345","true","false") returns "true"
ifEquals("41.6",".09","34","50") returns "50"
ifEquals("four","five","Y","N") returns "N"
ifEquals("four","four","t","f") returns "t"

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

  • In the first example, the ifEquals NSM predefined function compares the string specified in param1 ("345.000") with the string specified in param2 ("345"). Because the strings are equal, the ifEquals function returns the string "true" that is specified in onTrue.
  • In the second example, the ifEquals NSM predefined function compares the string specified in param1 ("41.6") with the string specified in param2 (".09"). Because the strings are not equal, the ifEquals function returns the string "50" that is specified in onFalse.
  • In the third example, the ifEquals NSM predefined function compares the string specified in param1 ("four") with the string specified in param2 ("five"). Because the strings are not equal, the ifEquals function returns the string "N" that is specified in onFalse.
  • In the fourth example, the ifEquals NSM predefined function compares the string specified in param1 ("four") with the string specified in param2 ("four"). Because the strings are equal, the ifEquals function returns the string "t" that is specified in onTrue.

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