On Mon, 29 Jul 2013, Logan Kelly wrote:
Hello,
I am using Gretl 1.9.12cvs on WIN 8. Is there a way to pass a list
series to a function? I used the following function declaration:
function void dplot(list lstDIV, string filetype, string strTitle[null], string
strDisc[null])
string ddat = varname(lstDIV[1])
sprintf send "%s", date(firstobs(@ddat))
end function
but get this error
The symbol 'DQ_us' is undefined
*** error in function dplot, line 24
> sprintf send "%s", date(firstobs(DQ_us))
So I am able to pass the list but the individual series are not
accessible? Anyway around this?
Using series names from a list within a function may be tricky, because of
possible name collisions. If I understood correctly what you want to do, I
suppose you can get some inspiration from the following small script:
<hansl>
function void myfunc(list X, scalar i)
names = strsub(varname(X),","," ")
printf "The %d-th series in %s is %s\n", i, argname(X),
strsplit(names, i)
end function
open AWM -q
list A = 7 8 9 10 11
myfunc(A, 4)
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------