NCalc evaluation error no viable alternative at input ','

1.7k Views Asked by At

I'm trying to evaluate an expression using NCalc.

iif(fval(hopo_pfd)="true",fval(hopa_basic)*12%,0)

But this expression is producing an error

no viable alternative at input ',' at line 1:46

All functions declared here are custom functions. But the event EvaluateFunction is not even raised. Please help.

1

There are 1 best solutions below

0
On BEST ANSWER

I believe you have invalid syntax. The expression: fval(hopa_basic)*12% includes the modulo % operator, but you haven't provided a divisor.

If you meant 12 percent, then it should be written in a decimal format: fval(hopa_basic)*0.12.

The reason it hasn't attempted to call EvaluateFunction to call your custom functions is because it failed to parse your expression syntax, let alone get to the stage of executing/resolving custom functions.