Calling a variable by its name

BlitzMax Forums/BlitzMax Programming/Calling a variable by its name

Raz(Posted 2006) [#1]
Is something like the follow possible in some sort of way

Const Level_001:Int = 500

Local WantedVariable:String = "Level_001"

Local OutputVariable:Int = VariableValue(WantedVariable)

to which OutPutVariable would become 500, hopefully that makes enough sense.

ta!


klepto2(Posted 2006) [#2]
In my opinion this make no sense, as you could simply doi like
this:
Const Level_001:Int = 500
Local OutputVariable:Int = Level_001

This was my first thought, but then I have got your idea behind this. You want to get your LevelInfo from a String, maybe you have const like Level_001, Level_002 etc.

Then this will maybe help you:




Raz(Posted 2006) [#3]
yeah, sorry i probably should have explained myself a bit better, I have a level editor with input boxes it'd be cool if I could supply the name of a variable to get its value :)

Ill give that code a look, much appreciated!