evaluate a string

BlitzMax Forums/BlitzMax Beginners Area/evaluate a string

Bertrand(Posted 2005) [#1]
Is it possible to evaluate the content of a string. I mean, if you have for example:
text:string = "Sin(25)"
how can i calcul the result.


skn3(Posted 2005) [#2]
By writting a math/function evaluator. Bmax is not run like a virtual machine, it is compiled.


bradford6(Posted 2005) [#3]
you may want to take a look at the LUA module


Bertrand(Posted 2005) [#4]
Super, the LUA is really good, thank's


ImaginaryHuman(Posted 2005) [#5]
You could also write a simple formula evaluator. I did one once based on counting the number of open and closed brackets and working through them in a nested manner to preserve the order of precedence. You could easily convert the string "Sin" into a function call to Sin, passing the value.