On Wed, 6 May 2015, Henrique Andrade wrote:
Dear Gretl Team,
As a part of my job in function package maintenance, I'm trying to make a
Hansl script to (1) create a list of functions available in the Gretl
internet server, (2) download them using the new "install" command and, (3)
execute the examples.
See if you like this:
<hansl>
function scalar chop_up(string line, bundle *ret)
bundle ret = null
# trim the beginning
string l = ""
string r = ""
string l = strstr(line, "current_fnfiles/")
string l = strstr(l, "<tt>")
string l = strsub(l, "</td><td>", " ")
string l = strsub(l, "</a>", "")
string l = strsub(l, "</td></tr>", "")
# now start chopping
string r = strstr(l, "</tt>")
scalar d = strlen(l) - strlen(r)
err = (d==0)
if err
return 1
endif
string ret["name"] = substr(l, 5, d)
l = r
string r = strstr(l, "</p>")
scalar d = strlen(l) - strlen(r)
err = (d==0)
if err
return 2
endif
string ret["author"] = substr(l, 11, d)
l = r + 7
string r = strstr(l, "</p>")
scalar d = strlen(l) - strlen(r)
err = (d==0)
if err
return 3
endif
string ret["version"] = substr(l, 3, d)
l = r + 7
string r = strstr(l, "</p>")
scalar d = strlen(l) - strlen(r)
err = (d==0)
if err
return 4
endif
string ret["date"] = substr(l, 3, d)
l = r + 9
string r = strstr(l, "</p>")
scalar d = strlen(l) - strlen(r)
err = (d==0)
if err
return 5
endif
string ret["description"] = substr(l, 1, d)
return err
end function
### -------------------------------------------------------------------------------
string functions_page =
readfile("http://ricardo.ecn.wfu.edu/gretl/cgi-bin/gretldata.cgi?opt...
string line = ""
bundles pkglist = null
loop while getline(functions_page, line) --quiet
string line = strstr(line, "current_fnfiles/")
bundle b = null
scalar err = chop_up(line, &b)
if !err
pkglist += b
endif
endloop
loop i=1..nelem(pkglist) --quiet
bundle b = pkglist[i]
printf "%4d: %s\n", i, b["name"]
endloop
</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
-------------------------------------------------------