Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: How do I get a boolen from the registry or convert a string "false" to boolean false?

  1. #21
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    No error message this time. But it does the opposite: It makes the inner part of the nested table to an integer, instead of the outer part. If that makes any sense.

    Probably not, so it's better to show it:

    Code:
    { -- #0
    this->   ["1"] = { -- #1
          ["1"] = 22,
          ["3"] = 5,
          ["2"] = 12,
          ["4"] = 0,
          ["Modus"] = 1,
       } -- #1,
    and this->   ["3"] = { -- #2
          ["1"] = 20,
          ["3"] = 5,
          ["2"] = 16,
          ["4"] = 0,
          ["Modus"] = 1,
    As you see it's the four temperatures that are numbers now, not the room number, in this case I have only shown rooms 1 and 3, and the room numbers are shown with "this and this".
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  2. #22
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    Code:
    if not Temperaturstyring then
    Temperaturstyring = {}
    end
    
    if not Temperaturstyring.Nettside then
        Temperaturstyring.Nettside = {}
    end
    
    if not Temperaturstyring.Nettside.SettTemperatur  then
        Temperaturstyring.Nettside.SettTemperatur = {}
    end
    
    
    local reg = win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\", 0);
    local keys = reg:ListKeys()
    reg:CloseKey()
    for i,key in pairs(keys) do
        local reg = win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\" .. key, 0);
        local valueNames = reg:ListValues()
        local t = {}
        for j, valueName in pairs( valueNames ) do
            
            t[ tonumber(valueName) ] = reg:Read( valueName )
            
        end
        Temperaturstyring.Nettside.SettTemperatur[ key ] = t
        reg:CloseKey()
    end
    Ron
    No support through PM

  3. #23
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    An error again, this time different:
    Code:
    [string "VM-Girder som hovedmaskin.gml:\Lys, ovner o..."]:23: table index is nil
    stack traceback:
        [string "VM-Girder som hovedmaskin.gml:\Lys, ovner o..."]:23: in main chunk
    The printout is empty:
    Code:
    { -- #0
    } -- #0
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  4. #24
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    then not all keys are numbers.

    t[ tonumber(valueName) or valueName ] = reg:Read( valueName )
    Ron
    No support through PM

  5. #25
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    And now I saw why. All the room number are numbers, but this code actually works on the middle level of the nested table. So the first code did the inner level (the temperatures of the different modes of the rooms), while this changes the middle level (the modes of the rooms). So if it's possible to go one more level out it will be what I'm
    looking for!
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  6. #26
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    Code:
    if not Temperaturstyring then
    Temperaturstyring = {}
    end
    
    if not Temperaturstyring.Nettside then
        Temperaturstyring.Nettside = {}
    end
    
    if not Temperaturstyring.Nettside.SettTemperatur  then
        Temperaturstyring.Nettside.SettTemperatur = {}
    end
    
    
    local reg = win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\", 0);
    local keys = reg:ListKeys()
    reg:CloseKey()
    for i,key in pairs(keys) do
        local reg = win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\" .. key, 0);
        local valueNames = reg:ListValues()
        local t = {}
        for j, valueName in pairs( valueNames ) do
            
            t[ tonumber(valueName) or valueName ] = reg:Read( valueName )
            
        end
        Temperaturstyring.Nettside.SettTemperatur[ tonumber(key) or key ] = t
        reg:CloseKey()
    end
    Ron
    No support through PM

  7. #27
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    Yes, yes, YES! That's it! It had the second level to number as well, but I managed to change that without messing up anything, so now it is exactly the way I wanted it! Thank you very much for this one, Ron! I think I will get the full system running this weekend now!

    The only thing I would like (yeah, I'm a bit greedy on your time now, I know) is if doesn't take too long to do the other one I had on the previous page. The registry read stuff that I had as a bunch of lines, since I can use that for more than one thing (in audio video as well as the heat control). Since the thread is a bit cluttered here's what it was:

    Code:
    Temperaturstyring.Nettside.status ={
    [1] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\1', 0):Read('Modus')),
    [2] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\2', 0):Read('Modus')),
    [3] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\3', 0):Read('Modus')),
    [4] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\4', 0):Read('Modus')),
    [5] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\5', 0):Read('Modus')),
    [6] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\6', 0):Read('Modus')),
    [7] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\7', 0):Read('Modus')),
    [8] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\8', 0):Read('Modus')),
    [9] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\9', 0):Read('Modus')),
    [10] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\10', 0):Read('Modus')),
    [11] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\11', 0):Read('Modus')),
    [12] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\12', 0):Read('Modus')),
    [13] = tonumber (win.CreateRegistry('HKEY_CURRENT_USER', 'Software\\Automatisering\\Termostat\\13', 0):Read('Modus'))
    }
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •