like in topic, is there any way to convert string into a mathematical notation?
For instance I have a string like “4 + 84 / 8” and I want Xojo to calculate that in mathematical order.
Is there any function, plugin etc. that would help me?
like in topic, is there any way to convert string into a mathematical notation?
For instance I have a string like “4 + 84 / 8” and I want Xojo to calculate that in mathematical order.
Is there any function, plugin etc. that would help me?
Which platform? On Mac and Linux, you can use the Shell and call “bc”.
On any platform, you can use XojoScript with a script like:
var x as double = <+formula+>
print x.ToString
You would replace “<+formula+>” with your actual formula, then capture the output from the XojoScript.
Or you could write your own parser.
Hi Dominik,
welcome to the forum. Interesting question !
On windows. How can I do that with XojoScript? I’m new to all the plugins and scripts and I don’t know how to use/make that
Start here:
https://documentation.xojo.com/api/code_execution/xojoscript.html
This is kind of an advanced task, so I’ll give you the general steps here. Please post your questions as you encounter them and we’ll try to help out.
Calculator
, that is a subclass of XojoScript
.Result As Double
.Print
event so it stores the message in Result
as a double.Calculate( formula As String ) As Double
.Source
to the script above with the formula inserted in the right place.Run
, then return the value in Result
.File>New Project>Examples>Advanced>XojoScript>Evaluator
Thank you so much!
Thanks for help to you too, I will give a try to understand these xojoscripts
Well sure, if you want to take the easy way…
(I forgot that was there.)