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.

dynamic variable name
#2
Like this, and make sure that v is defined before devices:
Code:
-- data get from webservice
v = {hum=1, tst='abc'}
log(v.hum, v.tst)

-- devices
devices = {
  {'9d', 'SENSOR', '8/4/5', v.hum},
  {'9e', 'COMMON', '8/4/6', v.tst}
}

-- print some data from v, based on data in devices
for k,k_items in pairs(devices) do
  -- log variable name
  log(k_items[4])
  -- log the data in variable with name k_items[4], for example the data in v.hum or v.tst (1 or abc)
end
Reply


Messages In This Thread
dynamic variable name - by gjniewenhuijse - 15.03.2021, 13:00
RE: dynamic variable name - by admin - 15.03.2021, 13:02
RE: dynamic variable name - by gjniewenhuijse - 15.03.2021, 13:04
RE: dynamic variable name - by admin - 15.03.2021, 13:05
RE: dynamic variable name - by gjniewenhuijse - 15.03.2021, 13:09

Forum Jump: