Hello
I have a string that contains a formula to evaluate to.
Is there any way to do it?
For example:
Var f As String = “2 + 3”
Of course the formula can be a bit more complicated.
Thank you
Hello
I have a string that contains a formula to evaluate to.
Is there any way to do it?
For example:
Var f As String = “2 + 3”
Of course the formula can be a bit more complicated.
Thank you
Search for XojoScript in the Xojo documentation.
You should be able to create a string containing Xojo code that performs the calculation, execute the string and retrieve the result.
new project
Examples/Code Execution/Xojoscript/Evaluator
Thanks to both of you
I have already solved it
@José_Miguel_Prefasi_Zapata : Feel free to share the solution you find to help other member of this forum
Thank you for that, I didn’t know this possibility.
How can I get the documentation? I searched for “Evaluator” but I didn’t get any usefull result. Anyway, the example gave me all what I need.
Another question, how can I add a XojoScript module? I add this one copying it from the example and pasting it in my project. But I’m curious how I can create a new XojoScript.
Hello
In Examples/Code Execution/Xojoscript/Evaluator is the Evaluator class
I have copied it (File, Export / File, Import) to my project and in the module where I need it I have added
Var myEval As New Evaluator
Var Formula As String
Var Result As UInteger
.
.
.
.
result = myEval.Eval(Formula)
In this case the results are always positive integers.
My project is to solve every problem from https://projecteuler.net/
Thank you all