Re: Convert string to variable name?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Convert string to variable name?
- From: Leo Razoumov <slonik.az@...>
- Date: 2013年3月28日 19:10:58 -0400
On Thu, Mar 28, 2013 at 6:51 PM, iain morland <iain@iainmorland.net> wrote:
> Hi all,
>
> I've created a table that contains a series of sequentially numbered
> variables. I'd like to retrieve those variable names from the table, in
> order to set an attribute that exists for those variables in the
> implementation of Lua that I'm using (5.1 with custom extensions in MOTU
> MachFive), but I'm having problems because Lua seems to interpret the names
> as strings, rather than as variables. I'm sure the fault is my lack of
> understanding, rather than a problem in Lua. :-s
If your variables are global variables they are are fields in a _G
table. You can easily get them like this
var= 123
print( _G["var"] )
--Leo--