Ah ok, I think I got it, Allin. Thank you for the workaround.

Cheers,
Artur


2013/4/19 Allin Cottrell <cottrell@wfu.edu>
On Fri, 19 Apr 2013, artur tarassow wrote:

> I've got another problem,
>
> I am trying check whether the variable "time" is present in list L1. This
> correct position is shown in the first example below. But if I add this
> inlist-command to a function environment, the scalar check2 = 0 but should
> be 2. I am using gretl (built: 2013-03-17) on Windows.
>
> <hansl>
> set messages off
> set echo off
> open denmark --quiet
>
> #Works
> ols LRM const time diff(LRM)
> L1 = $xlist
> scalar check1 = inlist(L1,const)
> check1
> scalar check2 = inlist(L1,time)
> check2
>
> #Within a function check2 gives the wrong result
> ols LRM const time diff(LRM)
> L1 = $xlist
> function void Ltest (list L)
>    scalar check1 = inlist(L,const)
>    print check1
>    scalar check2 = inlist(L,time)
>    print check2
> end function
> Ltest(L1)
> </hansl>

This is rather confusing, admittedly, but it's not exactly a
bug. The point is that series supplied to a function via a
list argument are in a different namespace from series defined
within the function. This would be more apparent if you tried

scalar check = inlist(L, d_LRM)

inside your function: you'd get an error, because the series
d_LRM is not "visible" as such within the function.

I'll think about this issue some more (and how best to resolve
and/or document it). But in the meantime you can do the test
you want by iterating over the list, as in

<hansl>
function void Ltest (list L)
   loop foreach i L
     if "$i" == "time"
       printf "time: list position = %d\n", i
     endif
   endloop
end function
</hansl>

Allin
_______________________________________________
Gretl-users mailing list
Gretl-users@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users