Hi,
i have a variable that i want to convert, exemple
3 to 1 2 3
4 to 1 2 3 4
6 to 1 2 3 4 5.
the thing is that i receive information about how many child to create, and i want a variable that keep the id in this type: 1 2 3 4 5 6.
thanks
Hi,
i have a variable that i want to convert, exemple
3 to 1 2 3
4 to 1 2 3 4
6 to 1 2 3 4 5.
the thing is that i receive information about how many child to create, and i want a variable that keep the id in this type: 1 2 3 4 5 6.
thanks
I typed this into an interactive Lua shell, so remove the “>” prompts in real code.
[code]> n = 6
a = {}
for i = 1, n do
table.insert(a,i)
end
s = table.concat(a, " ")
print(s)
1 2 3 4 5 6[/code]
The strategy is to build up an array in the variable a, and then stringify it with table.concat().
Thanks that work like a charm, thanks again.
Why not just keep MAX ID ?
MAXID = 6
The 1-5 are inferred.
Who will look at this ?
Best Home Automation shopping experience. Shop at Ezlo!
© 2022 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules