Where in the script are functions defined?

Q

Where in the script are functions defined?

A

A function can be defined at any place in the script.Defining a function does not call the function, it just creates the resource for it.

The definition must have been executed once before the function can be called, else you get a runtime error.

Example Code:

function newMainStateMachine()
    local sm=newStateMachine()
    local STATE_Init=0
    local STATE_InitStacks=1
    local STATE_Subscribe=2
    local STATE_Run=3
    local STATE_Error=100
    local STATE_NotSupported=200
    sm.INPUT_None=0
    sm.INPUT_Error=1
end