Tinderbox v9 Icon

Function arguments

Important note: all examples follow aTbRef naming conventions.

Function arguments

Each input argument must have a name, which is effectively a local variable used within the function. The argument name should not be an attribute reference, e.g. "$MyString", or an attribute's literal name, e.g. "MyString".

Arguments my be literal values (20, "Hello", false, etc.) or attribute references ($MyString). A function may, or may not, have one or more arguments. Multiple arguments are entered separated by commas (with optional whitespace after).

A value must be passed for every argument defined in the function. To simulate an optional argument, pass a placeholder string ("none") and test that input within the function's code before using the argument.

In aTbRef documentation any function arguments in the parentheses use the same CamelCase convention as for attribute names but with an 'i' prefix. For example, this function definition code:

function fMakeTable(iSomeList){ ... code ...}

'iSomeList' will be a variable available within the scope of the function, i.e. in the function but not outside it. Calling the above function like so:


will result in iSomeList within the function holding a list containing the value of the calling note's CategoryList attribute.

Using arguments within the function

Arguments are a received as a String data type (regardless of the source data in the calling code). Note that may change in future version, to allow enforced date-typing of arguments. But, at present assume type coercion occurs. That means most inputs will be assumed to be a String, List or Dictionary.

In the example above, calling the argument 'iSomeList' may indicate the term is a function argument and is intended to be List-type data, but it doesn't affect Tinderbox normal type coercion. A string with no semi-colons in it will be assumed to be a string. If semi-colons are found a list (essentially a List type) will be assumed.

To avoid incorrect parsing of inputs, it may be necessary to pass the input to a data-typed variable. Re-using the above example:

	function fMakeTable(iSomeList){
		var:list vList = iSomeList;
		// ... etc.

Variable use is discussed further here.

It is equally possible to pass the argument to an attribute of the desired data type in order to assert data type for further use within the function.

Evaluation of input arguments

An argument my be an expression as well as an attribute value, variable or literal string/number. For instance:


Here, the actual value passed to function fLastThreeWordsOf() is the evaluated result of fBestParagraphOf($Text), with $Text being the text of the calling note.

Next: Function arguments