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
  ...