Here I have a part of my code.
MyStateList=MyDevice.state it contains all attributes of a device.
MyDesc=MyDevice.description. In it I have a number (1) and a part of an URL string.
The number, MyCommands[1], is an index into the table MyStates.
I would like to get a MyValue=MyStates[MyIndex]
This does not work.
Code: Select all
MyStates = {}
for MyState in string.gmatch(MyStateList, "[^;]+") do
MyStates[#MyStates + 1] = MyState
print(#MyStates .. '-' .. MyState)
end
MyCommands = {}
for MyCommand in string.gmatch(MyDesc, "[^|]+") do
MyCommands[#MyCommands + 1] = MyCommand
print(#MyCommands .. '-' .. MyCommand)
end
MyIndex=MyCommands[1]
MyIPString=MyCommands[2]
MyValue=MyStates[MyIndex]
print(MyIndex) -- this gives 1
print(MyIPString) -- this gives part of the URL
print(MyValue) -- attempt to concatenate global 'MyValue' (a nil value)