This version is out of date, covering development from v9.5.0 to v9.7.3. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox v9 Icon

function


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Last Altered: 

Operator Uses Loop Variable Argument: 

 Statement  [other Statement type actions]

 Document  [operators of similar scope]

 Data manipulation  [other Data manipulation operators]

 Baseline

 9.5.0

 [More on loop variable arguments]


function

The function statement defines a user-defined function. Unusually as an operator function is used as a statement which is then followed by the definition of a user-named function fName. Thus:

function fName([argumentsList]){code}

Once defined a function is called in action code using the user-defined function name (here fName), as described here. Any function may several arguments or none at all. These are defined via a comma-delimited argumentsList. All arguments defined in the list are mandatory, unlike some action code operators which define some arguments as optional. In use, all defined arguments must be supplied, even if only as a default value, e.g. 0 for a number, etc.

All input arguments (the argumentsList) are available to use in code within the function. Thus by using the argument name as defined in the argumentsList, each argument's supplied value is retrievable anywhere within the function. Just as with a loop variable, the defined argument name is the code used to retrieve that argument's value.

As functions are more complex than other operators, their complete syntax and use is described in detail in the article on Functions and its sub-articles.

From v9.5.0, function declarations may optionally specify the date type of their input arguments, as passed via argumentsList.