lua-users home
lua-l archive

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


Hmmmmm? Well, you seem to be confusing strings with tables. I'm not sure what you are trying to do or exactly what your application
is. I mean assuming sensor was a table you can use constructs like:

sensor.large = ....

or 

suffix = "large"
sensor[suffix] = ...


However I would suggest you get a copy of "Programming in Lua" and read though that. It should have the answers you are looking for.


> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of
> Dan - Lintouch user
> Sent: Tuesday, October 24, 2006 3:26 PM
> To: lua@bazar2.conectiva.com.br
> Subject: Variable frankenstein
> 
> How to create new variable from mount name?
> 
> Trink.   multiples variables and fix sufix     ??.large , ??.small ??.tiny
> 
> check(S1) ---other file call function
> ---------
> function check(sensor)
> if not (sensor .. ".large" == nil) then    <--ok not error       var -> S1.large
>          sensor .. ".tiny" = 20     <--- get error               var->  S1.tiny
> end
> print( sensor .. ".tiny") --print
> end --end function
> 
> Or sugest corret implementation: clear, direct ,not complex.
> 
> 
> 
> 
> 
> 
> _______________________________________________________
> Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. Registre seu aparelho
> agora!
> http://br.mobile.yahoo.com/mailalertas/
>