That's Ok. In this case I leave my function as it is.
Thanks a lot
Federico
On jue, 2011-11-24 at 16:34 -0500, Allin Cottrell wrote:
On Thu, 24 Nov 2011, Federico Lampis wrote:
> have a question about the use the "smpl full" inside a function
> suppose this case:
>
> nulldata 50
> smpl 1 40
>
> smpl full
> series t1=time
> scalar nt=lastobs(t1)
>
> in a script these commands produce:
>
> Generated scalar nt = 50
>
> But if I write something like this:
>
> nulldata 50
> smpl 1 40
>
> function scalar example (----)
>
> smpl full
> series t1=time
> scalar nt=lastobs(t1)
> end function
>
> the scalar is nt=40. The question: there is some trick to recover the
> full sample inside a function or the last value of the original full
> sample without specify any argument about it in the function
> declaration?
The rule is that a function only has access to the data range that
was passed in by the caller. You can subsample within a function but
smpl --full just takes you back to the dataset state as the caller
specified it.
If you want a function to do something with a sub-sample and also to
do something with the full dataset, you can pass in the full dataset
(that is, do "smpl --full" before calling the function) but pass in
the sub-sample information as argument(s). For example int arguments
t1 and t2, or a dummy series.
Allin Cottrell
_______________________________________________
Gretl-devel mailing list
Gretl-devel(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-devel