lua-users home
lua-l archive

Re: Strings as Variables

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


> Markus Huber wrote:
>
> > How is it possible to check/use/access the value of a variable if the
> > variablename is hold in a stringvariable?
> >
> > e.g. MyValue = 10
> > MyString = 'MyValue'
> >
> > print (MyString) -- should print 10
> >
> > Is dostring() the right way? Not as simple as in php:
> No, it's getglobal() (provided that MyValue is global, of course):
> print (getglobal(Mystring))
> Oscar Lazzarino
Yes, that's true. But you should probably rephrase your program so that you
don't have to do that: store persistent data in a table instead of creating
global variables. Then you can just say
print (STATE[MyString])
Rici.

AltStyle によって変換されたページ (->オリジナル) /