Tinderbox v10 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.



See also—notes linking to here: