This version is out of date, covering development from v9.0.0 to v9.3.0. 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

Returning function values

Important note: all examples follow aTbRef naming conventions.

Returning function values


The return operator is only used inside a function, and if used is used only once per function operator call. The return statement returns a value from a function to the calling action code object (which can even be another function).

As the execution of the functions code stops once an expression containing a return (i.e. up to the next semi-colon) is processed. Thus, with the exception

Thus, when return is inserted in a function, the code/expression to the end of the line (or first semi-colon) is evaluated and returned. If the to-be-returned value is not a single term, it may be enclosed in parentheses. This helps indicate some evaluation is required before the single result is used as the return value The following all return some from of value to the caller:

return "Process complete"; 

return 2 + 2; 

return ("Hello " + vName"); 

return (iPrice * $Tax); 

Can there be a multiple value return?

If it is desired to pass multiple discrete values in the same return event, make the returned object a list or dictionary (or a variable of List, Set or Dictionary type).

Can there be more than one return call in a function?

Yes, if each return call is in a separate branch of the function code. For instance:

	function fTest(iString){
				return "Small string";
				return "Large string";
		return "No string";

In this case, there are three discrete possible return values but each closes and returns for a different branch of the code. The logic could as easily set a single variable in each branch and then use a single return at the end of the function. If using multiple return statements, take care to avoid exiting the function too early.

Next: Calling functions