Howto: expand variable
Posted: Sat Aug 22, 2009 3:22 am
How do I get a number from a string which is the name of a variable ...not a stringed number?
Example:
Global variable:
MyNumber = 10
function:
Function call:
testFunction( "My", "Number" )
Wanted Echo Result:
10
>> Got an Wrong Argument Error
I am lacking some sort of expandVariable(variable) function...
How can I solve this?
Any ideas?
Many thanks,
Eraldo
Example:
Global variable:
MyNumber = 10
function:
Code: Select all
testFunction(a, b)
local VariableNameString = a .. b
local value = tonumber( VariableNameString )
echo( value )
end
testFunction( "My", "Number" )
Wanted Echo Result:
10
>> Got an Wrong Argument Error
I am lacking some sort of expandVariable(variable) function...
Code: Select all
testFunction(a, b)
local VariableNameString = a .. b
local value = expandVariable( VariableNameString )
echo( value )
end
Any ideas?
Many thanks,
Eraldo