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

Re-using variables from other functions

Important note: all examples follow aTbRef naming conventions.


NOTE: this subject is only pertinent for more expert users

Those with a programming background my be used to techniques like re-using variables.

Can a function use variables from another function?

In theory, yes, as the example below shows. However, this is not recommended. Consider this code

	function fTest(iVal) {
		var:number vFactor=3;
		return fDoIt(iVal);
	};

	function fDoIt(iVal2) { 
		return vFactor*iVal2;
	};

	$MyNumber=fTest(7); // returns 21

As stated above, this usage—whilst possible—is not recommended.

If a variable needs to be shared in a wider scope, using a (user) attribute—either in the calling note i=or a specified note—is a perfectly practical alternative.