lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>How is it possible to check/use/access the value of a variable if the
>variablename is hold in a stringvariable?

As others have pointed out, use getglobal.
But check out gsub in the manual. Here is a variant of the examples given there:

 Lang = "Lua"
 Version = "4.0"
 print(gsub("This is $Lang version $Version","%$(%w+)",getglobal),"\n")

See test/examples/www for a use of this idea to create web pages based on
templates.

See also http://lua-users.org/wiki/HereDoc for a similar discussion.

>also possible with concatenation on the fly:

Again, getglobal as in getglobal("Ver".."sion")
--lhf