This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Create table within another table
#4
Hi,

Try this (enclose what you want in [ ... ] ):
Code:
Nombre_modo = grp.getvalue('32/1/21')
encendido_clima = grp.getvalue('32/1/22')
temperatura_clima = grp.getvalue('32/1/23')
velocidad_clima = grp.getvalue('32/1/24')

mytable = {}
mytable[Nombre_modo] = {}
mytable[Nombre_modo].encendido = encendido_clima
mytable[Nombre_modo]['temperatura'] = temperatura_clima
mytable[Nombre_modo]['velocidad'] = velocidad_clima
mytable.mysecondtable = {}
mytable.mysecondtable.encendido = encendido_clima
mytable.mysecondtable.temperatura = temperatura_clima
mytable.mysecondtable.velocidad = velocidad_clima
log(mytable)
But be carefull with this methode, your address 32/1/21 can hold a duplicate value and you might overwrite another table

Sample:
Code:
Nombre_modo = grp.getvalue('32/1/21') -- lets assume this holds value 'Test'
encendido = grp.getvalue('32/1/22') -- lets assume this also holds value 'Test'
mytable = {}
mytable[Nombre_modo] = {} -- Add a new empty sub tabel called 'Test'
mytable[Nombre_modo].value = 100 -- Add a new entry inside table 'Test' -> value with value 100
mytable[encendido] = {} -- This wil overwrite previous Nombre_modo as this is 'Test' and we add now a empty table {} 'Test'
                        -- so value = 100 is deleted
log(mytable)
BR,

Erwin
Reply


Messages In This Thread
RE: Create table within another table - by Erwin van der Zwart - 04.08.2020, 21:59

Forum Jump: