Hi All,
Recently I came with a requirement where I need to compute a string of multiple calculation as shown in an example below:
ProdMathEvaluator::evaluate(strRem(expr, ','));
Recently I came with a requirement where I need to compute a string of multiple calculation as shown in an example below:
int a = 100;
int b = 10;
int c = 5;
int d = 10;
int c = 5;
int d = 10;
Str s = "(a+b)/c*d"
need to get the calculated value for 's'.
str s could contain 'n' number of operation.
If it's Ax 2012 then we can use "formattedstr2num()" or "evalBuf()" but as these are deprecated from Dynamics 365, so here's an exact replacement for these inbuild function:
"ProdMathEvaluator::evaluate()"
Example:
Try to run the below code in job, it will help you to understand the code:
str expr = "(((1+2)*6)/5)";
info(num2str(ProdMathEvaluator::evaluate(expr),0,2,1,3));
Note: If you get the below error:
"Misuse of "Our expression", Please review the elements and symbols used in the equation."
This error comes with "ProdMathEvaluator::evaluate()" method, when our equation contains ',' symbol which majorly happens if value is greater than 999 like 1,000.0.
For this try to use strRem() to resolve the issue as follows:
Best Regards
Pranav Gupta
No comments:
Post a Comment