[Gretl-devel] append and sleep

Ignacio Díaz-Emparanza ignacio.diaz-emparanza at ehu.es
Thu Jan 18 04:33:55 EST 2007


El Miércoles, 17 de Enero de 2007 17:39, Allin Cottrell escribió:
> On Wed, 17 Jan 2007, Ignacio Díaz-Emparanza wrote:
> > Is there any relevant reason to restrict "append" for not using in a
> > loop? (I need it in a "foreach ..." loop).
>
> Probably not. I'll do some checking.
>
> > and, do we have a command to pause the execution of a gretl script? (as
> > "sleep" or "wait" in other languages)
>
> With a time parameter, as in "sleep 5" (seconds, maybe)?  That
> would not be difficult, if it's wanted.  Or a "press any key to
> continue" sort of thing?
>
> Allin

Now I need the first one, but probably it would be good to have the second one 
as well.

You may see my problem in the script below. The function tries to linearize 
automatically a list os series (interpolate missing observations and correct 
outliers) trough TRAMO. (It is not finished yet as it has some problems with 
missing data and unadjusted series). Gretl processes the line "append" some 
miliseconds before the previous Windows command has finished, so I need a way 
to slow down the execution of the "append" command. Uncommenting the three 
lines of the (unnneded) ARIMA loop pauses gretl a bit and works for me.

[to run it, you will have to correct the Windows paths]

----
open data9-9
set echo off
set messages off
scalar nobser = nobs(nocars)
scalar anyo=1959
#startp: start period
scalar startp=1
#period: periodicity
scalar period=4
#list xlist = nocars pop Y price primert
list xlist = price 
function tramolin clear
function tramolin(list xlist, scalar nobser, scalar anyo, scalar startp,  
scalar period)
 if nelem(xlist) = 0
    funcerr "The list of variables cannot be empty"
  end if
 loop foreach i xlist --quiet
  outfile --write "C:\Archivos de programa\gretl\tramo\$i"
  printf "%s\n", "$i"
  printf "%.8g %.8g %.8g %.8g\n", nobser, anyo, startp, period
  loop j=1..nobser --quiet
   scalar jj=j
   scalar dato = $i[jj]
   printf "%.8g\n", dato
  endloop
  printf "$INPUT RSA=3 $\n"
  printf "\n"
  outfile --close
  ! cmd /c "cd tramo && tramo -i $i -k $i.ser " 
  outfile --write "C:\Archivos de 
programa\gretl\tramo\graph\series\$i-lin.txt"
  printf "%s\n", "$i_lin"
  outfile --close
  ! cmd /c "cd tramo\graph\series && more +6 xlin.t >> $i-lin.txt"
#  loop i=1..2
#   arima 0 0 2 ; $i
# endloop
 endloop
end function
tramolin(xlist, nobser, anyo, startp, period)
append "C:\Archivos de programa\gretl\tramo\graph\series\price-lin.txt"



-- 
Ignacio Díaz-Emparanza
Dpto. de Economía Aplicada III (Econometría y Estadística)
UPV-EHU




More information about the Gretl-devel mailing list