Storing more values in one variable

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
DutchHans
Posts: 230
Joined: Friday 03 April 2015 20:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany (near dutch border)
Contact:

Storing more values in one variable

Post by DutchHans »

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
User avatar
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

Post by waaren »

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..
Do you ask this question for a specific language ?
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
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

Post by DutchHans »

Sorry,

It was in Lua...as far as I know.

Regards, Hans
User avatar
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

Post by jvdz »

I am using something like this:

Code: Select all

totalcontent=uservariables['Variable-Name']
for Name in string.gmatch(totalcontent, "[^|]+") do
	print('Name :'..Name)
end
This is using the verticalbar character as delimiter, so just use the one you like.
Jos
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

Post by DutchHans »

Thank you, i will giv it a try

Gr,Hans
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest