/
What shall be programmed in the scripts "initialization" phase?

What shall be programmed in the scripts "initialization" phase?

Q

What shall be programmed in the scripts "initialization" phase?

A

A.) Assignments of constant values like MY_STATE_INIT_DONE = 1 that need to be executed only once. This should cover also the definition of functions.

B.) Call of initialization functions of netSCRIPT specific services such as PortOpen() that need to be called only once during execution.

Example code:

if mystate == nil then
  MY_STATE_INIT_DONE, MY_STATE_1, MY_STATE_2 = 1,2,3 -- constants
  myfunction print() –- functions declarations
  ...
  end
  port = PortOpen() -- call of initializing functions
  myio = BusIoOpen()
  ...
  mystate = MY_STATE_INIT_DONE
else
  ...

Related content

Where are "constants" defined?
Where are "constants" defined?
More like this
How can you avoid that the whole script code is executed?
How can you avoid that the whole script code is executed?
More like this
Where in the script are functions defined?
Where in the script are functions defined?
More like this
Is a chained if-elseif conditional check proceeding all checks always independent if one check is true?
Is a chained if-elseif conditional check proceeding all checks always independent if one check is true?
More like this
In which order to use SYCON.net and netSCRIPT debugger with a scripting file for downloading?
In which order to use SYCON.net and netSCRIPT debugger with a scripting file for downloading?
More like this
How to behave in case of fatal errors not allowing to continue operation?
How to behave in case of fatal errors not allowing to continue operation?
More like this