Hi,
in January Jack mentioned a trick to inject an option value into a gretl
script when running the script from the command line. First of all that
is an undocumented thing (except if you do "gretlcli -h"), so I wanted
(and still want) to send at least a message to the users list for
reference. I guess it should also be added to the manual chapter "The
command line interface".
I put together the following example script which should be
self-explanatory:
<cli-script>
# Script to be run from the command-line/shell with gretlcli
# to test the "--scriptopt" trick, as in:
# > gretlcli scriptopttest.inp -b --scriptopt=3
if exists(scriptopt)
eval scriptopt
eval typestr(scriptopt) # gives "matrix" for me
if scriptopt == 3
print "Recognized as integer 3" # is printed
endif
else
print "Sorry, didn't work" # redundant, it works
endif
</cli-script>
One question I have before I send something like this to the users list,
why do I get typestr(scriptopt) == "matrix" ? I thought perhaps gretl is
expecting/allowing a matrix there, but then I tried the following command:
<shell-command>
gretlcli scriptopttest.inp -b --scriptopt={1;2}
</shell-command>
...and the output I got was:
? eval scriptopt --- so exists(scriptopt) must be true!
0 --- where does this come from?
? eval typestr(scriptopt)
null --- neither "0" nor "{1;2}" should give this!
So some more minor mysteries appearing here...
thanks,
sven
Show replies by date