Good evening everyone,
Months ago a read here on the forum that someone explained how to store more values in one variable, I believe I remember something with devided by semicolons... I can't find it here on the Forum anymore..
Can someone put me in the right direction.. writing and reading more than one value in/out of a uservariable.
ie. Titel,value1,value2,value3 all in one variable
Thanks in advance.
Hans
Storing more values in one variable
Moderators: leecollings, remb0
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Storing more values in one variable
Do you ask this question for a specific language ?DutchHans wrote: Saturday 18 August 2018 17:59 ..
Months ago a read here on the forum that someone explained how to store more values in one variable, I believe I remember something with devided by semicolons... I can't find it here on the Forum anymore..
In most programming languages you can store many values in a table or in a string. The table approach is native but for the string approach you need functions to store and retrieve the individual values.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
DutchHans
- Posts: 230
- Joined: Friday 03 April 2015 20:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Germany (near dutch border)
- Contact:
Re: Storing more values in one variable
Sorry,
It was in Lua...as far as I know.
Regards, Hans
It was in Lua...as far as I know.
Regards, Hans
- jvdz
- Posts: 2446
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Storing more values in one variable
I am using something like this:
This is using the verticalbar character as delimiter, so just use the one you like.
Jos
Code: Select all
totalcontent=uservariables['Variable-Name']
for Name in string.gmatch(totalcontent, "[^|]+") do
print('Name :'..Name)
endJos
-
DutchHans
- Posts: 230
- Joined: Friday 03 April 2015 20:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Germany (near dutch border)
- Contact:
Re: Storing more values in one variable
Thank you, i will giv it a try
Gr,Hans
Gr,Hans
Who is online
Users browsing this forum: Bing [Bot] and 1 guest