On Thu, 14 Jun 2007, Ignacio Diaz-Emparanza wrote:
[In Sven's example] "endogenous" is a list, so this
implies that
the user should define it first:
list endogenous = income
list components = decomp(endogenous)
and I think that, given that my function does not need more than
one input variable, gretl should have a way to obtain the same
effect with only one line:
list components = decomp(income)
May be the function "varname()" of the "sprintf" command can
help in doing something like that?
I may be missing something, but I think the answer is that you'll
have to pass a list to achieve what you want here.
The trouble is that when a single series is passed to a function,
this series is known inside the function by the name of the
corresponding function parameter, _not_ by the name it has in the
calling script.
function foo (series y)
<create list of variables based on y>
return list modlist
end function
list foolist = foo(myvar)
In the above, function foo has no way of knowing that the series
it sees as "y" is known as "myvar" in the caller.
One way around this would be to allow string arguments to
user-defined functions.
Allin.