Script Initialization (INIT Call)

When working with a component that does not have data feeding into it, how do you start the component?

In IguanaX components, we use the design logic of calling the main(Data) function with Data equal to “INIT“ by including INIT in the Translator’s Sample Data. This is the Lua code structure:

function main(Data) if Data == "INIT" then -- do some initialization return end end

By adding INIT to your sample data you can initialize variables in memory or load setup tasks before your main script is run. This allows for more adaptable behaviour of your component script.

Using INIT as sample data also allows for you to see your initialization setup in the logs of the component.

INIT logic is useful for initializing any variable, configuration or parameter you only need to run once, when the component first starts. For example, pre-populating any constants that will be used by the main script or establishing network connections with a web service or database.

Â