I am very close to a working setup of choosing web radio channels and turning on and off amps from the webserver. The only thing I still need is the ability to get the currently playing channel from the Windows system registry and into a table. I have a similar system running for temperature control in the house, but I was unable to modify it for use in this (probably because it's slightly different in the layers). The system registry is in this format:

Code:
[HKEY_CURRENT_USER\Software\Automatisering\Lydogbilde\Radiokanal]

[HKEY_CURRENT_USER\Software\Automatisering\Lydogbilde\Radiokanal\1]
"Radiokanal"="2"

[HKEY_CURRENT_USER\Software\Automatisering\Lydogbilde\Radiokanal\10]
"Radiokanal"="0"

[HKEY_CURRENT_USER\Software\Automatisering\Lydogbilde\Radiokanal\11]
"Radiokanal"="1"
So each zone has it's own subkey under the key Software\Automatisering\Lydogbilde\Radiokanal, numbered from 1-20. It's the value "Radiokanal" (radio channel) that I want to put into a table with "true" for the channel that's running and "false" for the other 9 channels in the system. I can create an empty table with all entries like this:

Code:
LydogBilde = LydogBilde or {}
LydogBilde.Radiokanal = LydogBilde.Radiokanal or {}
LydogBilde.SettRadiokanal = LydogBilde.SettRadiokanal or {}
LydogBilde.Nettside = LydogBilde.Nettside or {}
LydogBilde.Nettside.Radiokanal = LydogBilde.Nettside.Radiokanal or {} 


local max_n = table.getn(LydogBilde.SoneID)
local n
local kanal

local kanal_lookup = {
[0] = "0",
[1] = "1",
[2] = "2",
[3] = "3",
[4] = "4",
[5] = "5",
[6] = "6",
[7] = "7",
[8] = "8",
[9] = "9",
}

for n = 1,max_n,1 do
    for kanal = 0,9,1 do
        local kanal_string = kanal_lookup[kanal]
        LydogBilde.Nettside.Radiokanal[kanal_string] = LydogBilde.Nettside.Radiokanal[kanal_string] or {}
        LydogBilde.Nettside.Radiokanal[kanal_string][n] = "false"
    end
end
This gives me a table that looks like this and has ten nested tables, one for each channel showing if it's playing in zone 1-20 (only the two first channels are here for illustration):

Code:
{ -- #0
   ["1"] = { -- #1
      [1] = "false",
      [2] = "false",
      [3] = "false",
      [4] = "false",
      [5] = "false",
      [6] = "false",
      [7] = "false",
      [8] = "false",
      [9] = "false",
      [10] = "false",
      [11] = "false",
      [12] = "false",
      [13] = "false",
      [14] = "false",
      [15] = "false",
      [16] = "false",
      [17] = "false",
      [18] = "false",
      [19] = "false",
      [20] = "false",
   } -- #1,
   ["0"] = { -- #2
      [1] = "false",
      [2] = "false",
      [3] = "false",
      [4] = "true",
      [5] = "false",
      [6] = "false",
      [7] = "false",
      [8] = "false",
      [9] = "false",
      [10] = "false",
      [11] = "false",
      [12] = "false",
      [13] = "false",
      [14] = "false",
      [15] = "false",
      [16] = "false",
      [17] = "false",
      [18] = "false",
      [19] = "false",
      [20] = "false",
   } -- #2,
But can anybody please help me with how to convert the channel numbers in the registry showing what's playing in each zone to this table? If it's unclear I can upload a sample of code that does just about the same thing for my heat setup, but which I can't manage to modify. This is the code I'm trying with, that doesn't work:

Code:
local max_n = table.getn(LydogBilde.SoneID)
local n
local kanal

local kanal_lookup = {
[0] = "0",
[1] = "1",
[2] = "2",
[3] = "3",
[4] = "4",
[5] = "5",
[6] = "6",
[7] = "7",
[8] = "8",
[9] = "9",
}

LydogBilde.Nettside.Radiokanal ={
[1] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\1', 0):Read('Radiokanal')),
[2] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\2', 0):Read('Radiokanal')),
[3] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\3', 0):Read('Radiokanal')),
[4] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\4', 0):Read('Radiokanal')),
[5] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\5', 0):Read('Radiokanal')),
[6] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\6', 0):Read('Radiokanal')),
[7] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\7', 0):Read('Radiokanal')),
[8] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\8', 0):Read('Radiokanal')),
[9] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\9', 0):Read('Radiokanal')),
[10] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\10', 0):Read('Radiokanal')),
[11] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\11', 0):Read('Radiokanal')),
[12] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\12', 0):Read('Radiokanal')),
[13] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\13', 0):Read('Radiokanal')),
[14] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\14', 0):Read('Radiokanal')),
[15] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\15', 0):Read('Radiokanal')),
[16] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\16', 0):Read('Radiokanal')),
[17] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\17', 0):Read('Radiokanal')),
[18] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\18', 0):Read('Radiokanal')),
[19] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\19', 0):Read('Radiokanal')),
[20] = tonumber(win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\LydogBilde\\Radiokanal\\20', 0):Read('Radiokanal')),
}

local kanal_string = kanal_lookup[kanal]
print(kanal_lookup[kanal])

for n = 1,max_n,1 do
    for kanal = 0,9,1 do
        local kanal_string = kanal_lookup[kanal]
        LydogBilde.Nettside.Radiokanal[kanal_string] = LydogBilde.Nettside.Radiokanal[kanal_string]
        LydogBilde.Nettside.Radiokanal[kanal_string][n] = true
    end
end
I have spent several hours today trying to get it to work, and now it's 11 P.M. and I need to quit for my own sanity's sake. I don't think I can get any further anyway, I've been running around in circles the last couple of hours. I need it to be the registry (like the working heat system) because I have more than one program that accesses the data from there. So please help me out of my misery! I will of course be ready tomorrow morning to explain anything that's unclear or upload any parts of the system that you would like to see if necessary.