There's an extension of gretl's shell capabilities in the works.
Sorry, not available for Windows just yet, but on *nix you can now
(current CVS) capture output from shell commands in a string
variable, using "$(command)", and you also have a subset of C's
sscanf to process such strings.
Here are a few examples:
<script>
nulldata 10
string fnum = $(ls | wc -l)
scalar n
sscanf @fnum, "%d", &n
printf "There are %d files in this directory\n", n
string bessel = $(echo "j(3,10)" | bc -l)
scalar j
sscanf @bessel, "%lf", &j
printf "Bessel function, order 3, of 10 = %.15g\n", j
! echo "1 2 3 4" > mat.txt
! echo "5 6 7 8" >> mat.txt
string mat = $(cat mat.txt)
printf "mat (string form) = \n%s\n", @mat
matrix m
sscanf @mat, "%m", &m
print m
</script>
The allowable sscanf conversions are "d" (int), "lf" (double),
"s" or "[stuff]" (string) and "m" (matrix). With matrix
conversion we proceed along the input string so long as we're able
to read doubles, with space or tab counting as column separator
and CR-LF, LF or CR counting as row separators.
Allin
Show replies by date