-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to evaluate variables #49
Comments
Hello @trrahul. This because a variable contains a C# object and in your case. variables evaluator.Evaluate("c+d");
// or if
evaluator.Variables["h"] = "Hello";
evaluator.Variables["w"] = "World";
evaluator.Evaluate("h+\" \" +w"); you get :
but if you want to evaluate a string in a evaluation you could do something like this : evaluator.Evaluate("Evaluate(c)");
evaluator.Evaluate("Evaluate(d)"); And then you will get :
See Custom variables and Functions for more infos |
After a little thought. I think it might be good to introduce a type of variable that could be evaluated when encountered to better answer to this issue. evaluator.Variables["c"] = new SubExpression("a+b");
evaluator.Variables["d"] = new SubExpression("c+3"); I Reopen this issue and will work on it for the next version of ExpressionEvaluator. |
Isn't it better to search for the variables in the expression and evaluate them in order instead of creating a new subexpression? Because in this case, please correct me if I am wrong, every variable has to be created as a subexpression if they are used later in another expression. |
You need to understand that variables are just containers like C# variables or any programming language variables. It could contains anything (string, int, float, Regex, File or a custom class...) and a
No if a variable is just a value like your variables But of course if you also encapsulate |
Thanks for the clarification. I was trying out different expression evaluators and this issue happened with all the libs I tried except lambdaparser. It was able to evaluate the expression correctly, but it had another problem ExpressionEvaluator did not have. nreco/lambdaparser#22 |
I just published version 1.4.9.0 that allow to the use of SubExpression here is the doc on the wiki SubExpression variable |
I used the following code.
The output was
Shouldn't the output be the following?
The text was updated successfully, but these errors were encountered: