Eval strings to commands?

BlitzMax Forums/BlitzMax Programming/Eval strings to commands?

orgos(Posted 2009) [#1]
Hi people.

There his any way to eval strings like JavaScript to execute the commands inside the strings?

for example

Local aa:String = "Hello world"
Local bb:String = "Print aa"

Eval(bb)


plash(Posted 2009) [#2]
No there is not (nothing official anyhow).


Htbaa(Posted 2009) [#3]
It's possible in Javascript, Perl, Lua, PHP and any other scripting language because it's a scripting language. It gets interpreted at runtime. BlitzMax doesn't allow this because you have to compile your code before being able to run in.


xlsior(Posted 2009) [#4]
Note that there are LUA modules for blitzmax that allow you to add LUA scripting to your Blitzmax program -- but it is a seperate languatge, you wouldn't be able to run straight blitz code through it.


orgos(Posted 2009) [#5]
thanks for the answers. i see how to implement the LUA scripting feature.


beanage(Posted 2009) [#6]
write your own interpreter and share it. that would be awesome ;)


Czar Flavius(Posted 2009) [#7]
Perhaps with tons of function pointers and variable pointers, and reflection you could maybe parse strings of BM code at runtime.. or a simplified varient of the language that satisfies your needs. So get object names from the text and reflect on objects to find that object. And when you see Print, you set an execution pointer to the Print function. And then pass it that object.


beanage(Posted 2009) [#8]
I remember i once, long time ago, wanted to do the same, and.. I did neither know there are pointers nor there's reflection ... :
Select Lower input
   Case "Print"
   Case "IncrAmmo"
   Case "DecrAmmo"
   ..
End Select


Thats aweful!