In CVS and Windows snapshot you can do the following (revised
version of Ignacio's sample script):
<script>
function sillyfun (string foo, series x)
series @foo_f1 = x+x(-1)+x(-2)+x(-3)
series @foo_f2 = x+x(+1)
list outlist = @foo_f1 @foo_f2
return list outlist
end function
open data9-9
string sname="nocars"
list alist = sillyfun(sname, nocars)
print alist
</script>
Alternatively, you could give the string argument to sillyfun as a
quoted string literal:
list alist = sillyfun("nocars", nocars)
I just downloaded gretl from CVS and the script does not work (In Kubuntu
Linux). The output I obtain is
gretl version 1.6.6.pre2
Current session: 2007/11/07 10:00
? function sillyfun(string foo, series x)
series @foo_f1 = x+x(-1)+x(-2)+x(-3)
series @foo_f2 = x+x(+1)
list outlist = @foo_f1 @foo_f2
return list outlist
end function
? open data9-9
Read datafile /opt/gretl/share/gretl/data/data9-9.gdt
periodicity: 4, maxobs: 60,
observations range: 1976:1-1990:4
Listing 7 variables:
0) const 1) nocars 2) pop 3) Y 4) price
5) primert 6) unemp
? string sname="nocars"
Saved string as 'sname'
? list alist = sillyfun(sname, nocars)
Data types not conformable for operation
Error executing script: halting
list alist = sillyfun(sname, nocars)
--
Ignacio Diaz-Emparanza
DEPARTAMENTO DE ECONOMÍA APLICADA III (ECONOMETRÍA Y ESTADÍSTICA)
UPV/EHU
Avda. Lehendakari Aguirre, 83 | 48015 BILBAO
T.: +34 946013732 | F.: +34 946013754
www.et.bs.ehu.es