Is Not a Number
Overview
This function checks if a parameter is not a number:
- Returns true if the parameter is not a number.
- Returns false if the parameter is a number.
CHelper.Math.IsNaN(Parameter)
The parameter of this function can be defined as an XPath, variable, or number.
Considerations
- The supported attribute types to use as input XPath parameter (or Xpaths stored in variables) are: integer, currency, float, real.
Example
Suppose you want to evaluate if the parameters to be used in a Math function are numbers in order to avoid errors or incoherent results. To do so you can use the IsNaN function:
//Evaluate if of the parameters to be used in the average function are numbers
Number1IsNotaNumber=CHelper.Math.IsNaN(<Product.Price1>);
Number2IsNotaNumber=CHelper.Math.IsNaN(<Product.Price2>);
if (Number1IsNotaNumber==true || Number1IsNotaNumber==true)
{
//If not show an error message
CHelper.ThrowValidationError("The parameters of the Average function must be numbers");
}else{
//If so, apply the math function
CHelper.Math.Average([<Product.Price1>,<Product.Price2>]);
}