5500SHAC User libraries include problems

Discussion in 'C-Bus Automation Controllers' started by Chris Peck, Jul 24, 2018.

  1. Chris Peck

    Chris Peck

    Joined:
    Jun 1, 2018
    Messages:
    7
    Likes Received:
    0
    Hi all,

    I'm having trouble getting any user created libraries to run correctly. Everything is fine if I run in the one common functions file but if I split out and try to include a module it doesn't work. Can anybody tell me what I'm doing wrong?

    Simple example that does not work -

    In user libraries I have a file caller user.testing -
    Code:
    local testing = {}
    
    function testing.foo()
        log('Hello World!')
    end
    
    return testing
    In the resident files I have a file that does -
    Code:
    script.enable('user.testing')
    local testing = require 'user.testing'
    log('running resident test')
    testing.foo()
    The only log output I get is
    No errors are showing in the log but no log output from the testing.foo function is printed either. Any ideas??
    Cheers,
    Chris
     
    Chris Peck, Jul 24, 2018
    #1
  2. Chris Peck

    daniel C-Busser Moderator

    Joined:
    Jul 26, 2004
    Messages:
    766
    Likes Received:
    20
    Location:
    Adelaide
    Hi Chris,

    Perhaps the SHAC is doing things slightly different to the Lua norm when including other scripts.

    My resident script simply looks like this:
    Code:
    require("user.dateparse")
    
      local result = dateparse.parse(datestring)
    
    My user script looks much like yours:
    Code:
    dateparse = {}
    
    function dateparse.parse(s)
      ..
    end
    
    return dateparse
    [CODE]
     
    daniel, Jul 24, 2018
    #2
  3. Chris Peck

    Chris Peck

    Joined:
    Jun 1, 2018
    Messages:
    7
    Likes Received:
    0
    Thanks! That helped a lot. After using your code for testing it seems the problem was actually more to do with having to disable the script then re-enable it after editing. If that isn't done it doesn't seem to reload any changes.
     
    Chris Peck, Jul 25, 2018
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.