On Tue, 5 Jan 2016, cociuba mihai wrote:
[W]hen trying to run the script from
http://lists.wfu.edu/pipermail/gretl-users/2014-January/009553.html in
order to set the description to the variables I receive the following error:
#########
? string line
? scalar i = 1
Generated scalar i = 1
? loop while getline(D, line) -q
> setinfo i --description="@line"
> i++
> endloop
Command has insufficient arguments
>> setinfo i --description="@line"
##########
Any ideas of what seems to be problem?
Ah, the example you cite dates from January 2014, and since then we
have made substantial changes to the gretl command interpreter. You're
right, the particular phrasing of that loop no longer works.
Arguably, it was only by a strange hack that it worked in the first
place. The argument to "setinfo" should be the name or ID number of a
series; at the time of writing that script, the scalar variable named
"i" was being read as containing the ID number of a series -- that's
what I'm describing as a strange hack (since in general in gretl
commands you cannot give the name of a scalar where the name of a
series is required).
Anyway, here's a version that will work with current gretl:
<hansl>
open prod.txt
string D = readfile("pnames.txt")
string line
loop i=1..$nvars-1 -q
getline(D, line)
setinfo $i --description="@line"
endloop
labels
</hansl>
Note that here we're using "$i" (string substitution) to get the name
of the series into the "setinfo" command. Here's another variant of
the loop that will work (treating the argument to "setinfo" as a list
with a single member):
<hansl>
loop i=1..$nvars-1 -q
getline(D, line)
list Li = i
setinfo Li --description="@line"
endloop
</hansl>
Allin Cottrell