it took me a long time to figure out to do this:
i=RecursionTest (par)
as before when I had it just as this:
RecursionTest (par)
~OR~
x=RecursionTest (par)
I kept getting:
parameter: 1
parameter: 2
parameter: 3
parameter: 4
RESULT: 1 or 2
and even before this, with an earlier code set up, I got this:
parameter: 1
parameter: 2
parameter: 3
parameter: 4
error: ~"could not do return script"
RESULT: 0
-----------------------
I was able to get the parameters:
parameter: 1
parameter: 2
parameter: 3
parameter: 4
to work correctly pretty quickly, with this:
<function name="RecursionTest" parameters="i" type="int"><![CDATA[
msg ("parameter: " + i)
if (i < 4) {
par = i+1
RecursionTest (par)
}
]]></function>
but, I was having a hard time trying to figure out why it wouldn't then work with the "return (i) for the RESULT: 4", as it had seemed that it should with it correctly updating for each of the parameters' values.
this is what was happening (as best as I understand it... barely at all, lol):
<function name="StartRec">
i=1
result=RecursionTest (i -> 1)
<function name="RecursionTest" parameters="i -> 1" type="int"><![CDATA[
msg ("parameter: " + 1)
if (1 < 4) {
par = 1+1
RecursionTest (par -> 2)
<function name="RecursionTest" parameters="par -> 2" type="int"><![CDATA[
msg ("parameter: " + 2)
if (2 < 4) {
par = 2+1
RecursionTest (par -> 3)
<function name="RecursionTest" parameters="par -> 3" type="int"><![CDATA[
msg ("parameter: " + 3)
if (3 < 4) {
par = 3+1
RecursionTest (par -> 4)
<function name="RecursionTest" parameters="par -> 4" type="int"><![CDATA[
msg ("parameter: " + 4)
(Quest comes to a missing link, hence its output of an~the ERROR message)
}
return (i -> 0, 1, or 2 ~ due to never setting "i" as the updated~adder value from the repeated "RecursionTests", we were using the repeatedly updated~adder "par" variable: 1->2->3->4, but our "i" variable is unused, and remains as initially setted, at: "1")
</function>
msg ("RESULT: result -> 0, 1, or 2 ~ due to never setting "i" as the updated~adder value from the repeated "RecursionTests", we were using the repeatedly updated~adder "par" variable: 1->2->3->4, but our "i" variable is unused, and remains as initially setted, at: "1")
</function>
but, as can be seen, we've got no connector~link to~for the "return (i)", so quest sees a~the missing function's return value, thus the error: ~"could not find function, no return value"
AND, we've never set the updating of the "i", hence the (still mysterious) return of "0 (zero)", and (non~less-mysterious) return of "1" or "2", within the "RESULT: X"
--------------------------
tinker with my code yourself, to see how you can mess it up, and maybe understand better what is going on than I can, and it's easier for you to see the bad results yourself from tinkering with my code, than me trying to explain this to you without you getting confused from me not being able to recall exactly what I had coded when I got these bad results of mine, and nor do I want to re-tinker with it myself, as I've already done so long enough just to finally get my working code done for you, lol.