This code snippet shows how to calculate a mathematical expression and get the result in X++ code (the shown code is made as a job):
static void calc(Args _args)
static void calc(Args _args)
{
XppCompiler x;
// In str s we write the expression that we want to evaluate
Str s = "1+2*(8+4)*cos(25)";
Str result;
;
x = new XppCompiler();
if (x.compileExpr(s))
{
result = x.execute();
}
else
{
result = "Error in formula";
}
info(result);
}
Comments
Post a Comment