Return value and local variables

four simple functions:

function noOne() {
	var:string returnValue = "";

	returnValue = noTwo();

	return returnValue;
};
function noTwo() {
	var:string returnValue = "";

	returnValue = "Jippiii";

	return returnValue;
};
function noOneB() {
	var:string returnValue = noTwoB();

	return returnValue;
};

function noTwoB() {
	var:string returnValue = "Yahooo";
	
	return returnValue;
};

and two stamps:

$Text = noOne();

and

$Text = noOneB();

The first one will return nothing, the 2nd stamp will return a value.

Shouldn’t the first syntax work too?

returnValueTest.tbx (150.3 KB)

I think the first one should return a value.

I’ll investigate. Thanks to the wonders of modern dentistry, a git bollix, and a looming paper deadline, it might have to wait for Monday.

1 Like

Adding to the mystery.
Changing “returnValue” to “rValue” in functions “noOne()” and “noTwo” makes the day.
Seems to point to some kind of initialization problem.

1 Like

“returnStr” will not work either, “returValue” will work. Seems to me that “return” is a magic keyword for TBX.

Ah. I bet the lexer for return is over-eager. I’m gradually getting back into the swing after my close encounter with Modern Dentistry; I should have this resolved soon.

1 Like

Yes indeed!

The token returnVal is being parsed as return Value. There’s more: the token ‘variable’ is parsed as ‘var iable’ and created a local var named ‘iable’. Ouch!

This will be fixed in the next backstage release and the next release.

3 Likes