geo wrote: ↑Thu Jul 15, 2021 7:50 pm
it won't work
As Sparkout says, your firstFunction() can
only return a single value (a comma-delimited list of values in this case).
Therefore your forecast() function needs to parse out the parameters from the list returned by firstFunction() and then use them.
or to put it differently, your forecast() function is expecting 5 parameters but only receiving one (the list returned by firstFunction). The list you get out of firstFunction() is seen as pXactual by forecast(), with all other parameters empty.
If you jut wanted to have the 1 function to cater both for passing 5 values directly and for cases where a single list (of 5 values) is passed back, just check that your parameters are not empty and act accordingly
eg:
Code: Select all
function forecast pXactual, pX1, pX2, pY1, pY2
local tXactual, tX1, tX2, tY1, tY2
if pX1 is empty and pX2 is empty and pY1 is empty and pY2 is empty then
//assume the value passed as pXactual is in fact a list of the 5 values in the order specified
put item 1 of pXactual into tXactual
put item 2 of pXactual into tX1
put item 3 of pXactual into tX2
put item 4 of pXactual into tY1
put item 5 of pXactual into tY2
return (tY2 + (tXactual - tX2) / (tX1 - tX2) * (tY1 - tY2))
else
return (pY2 + (pXactual - pX2) / (pX1 - pX2) * (pY1 - pY2))
end if
end forecast
not tested, but would expect this to work
This does however rely on the order of the list of the list being correct. You may wish to return an array from firstFunction() so that there is no ambiguity...