/
Main.lua

Main.lua

Every Translator component contains an entrypoint, the main.lua module.

This module contains the main() function.

When you start a component, the Translator runs through the entire script in main.lua. Every time a running component receives a message, the main() function is called.

One thing to note is that variables are initialized at different times depending on where they are declared.

  • Variables declared outside the main() are initialized once when the component is started.

  • Variables declared within the main() are initialized every time a message is processed by the running component.

Keep main.lua short and sweet! main.lua should be a treated like a table of contents, all the major activities or functions should live in local modules or libraries and be called by the main() function.

 

Related content

Structuring Component Translators
Structuring Component Translators
More like this
From FTP
Read with this
Lua File (*.lua)
Lua File (*.lua)
More like this
Transforming Messages: HL7 to JSON
Transforming Messages: HL7 to JSON
Read with this
Script Initialization (INIT Call)
Script Initialization (INIT Call)
More like this
How Lua Code is Run in the Translator: Caching Variables
How Lua Code is Run in the Translator: Caching Variables
More like this