Setup in a Function Node

Hi to all,
A probably stupid question...how can I use the setup tab in a function Node?

I need to set the Var i = 0 for the first time that the function node is called, and then go on with the code written in the function tab.

Is there a special syntax to put in the setup tab?

Thanks to all

Hi @LucaCarminati

Each of the setup, function and close functions run in their own scope. Any variables you declare in one are only visible in that one.

This is where you can use the context object - which is shared between the functions.

In this instance you'd do:

context.set('i',0);

in the setup tab, and then:

var i = context.get('i');

in the main function .

1 Like

Hi @knolleary ,

Thanks a lot!
I have used yet the context var until now, and I thought that the Setup tab could be used for the initial setup of the variables (without using the context); I will use your solution.

Thanks again!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.