This topic contains 1 reply, has 2 voices, and was last updated by  Eliot Muir 2 years, 11 months ago.

db.connect outside main(): Parameters outside channel

  • I have my db.connect{} outside of main() for performance reasons but a new requirement states the db parameters must be held in an external file. It’s trivial to do this if the connect is done inside main, but how can I get the parameters into the filter if connect{} is outside main? Thank you in advance.

    Just a matter of writing a function and calling it in the body of the main lua module for the translator instance.

    In reality when you write:

    local DB = db.connect{...}

    It’s actually doing a function call to that function.

    Sometimes for debugging if I can be bothered I will write a function which uses a boolean variable outside of main like this:

    local Initialized = false
    function Init()
       if not Initialized then 
           -- Do initialization       
           Initialized = true;
    function main(Data)

    The nice thing about this is that you get annotations and intellisense so it makes it easier to write the code.

You must be logged in to reply to this topic.