I disagree with your proposed syntax.
I should know that the current form of the loop for, comes from the C language (and then C++ and Java).
I think that we could have something like:
loop n in 6 12 24 xlist

Where  n is the loop variable 6, 12 and 24 are numbers, and xlist is a list of the same type of n. This way we could have:
loop a in "G" "r" "e" "t" "l"
or
loop a in alist, where alist is a list of strings.

I am avoiding using the loop foreach, because it uses numbers to index variables.

Is this a valuable command? The cost of developing it (and maintain), seems too high for the value it brings.

Regards,
Hélio
On Tue, May 25, 2010 at 10:00 PM, Henrique Andrade wrote:
Dear Riccardo, Kehl and Guilherme,

I was looking for something simple. The option "loop for (n=6; n<=24; n*=2)" worked just fine. But in my humble opinion the option "loop for (n=6; n=12; n=24)" should work too, but this is not a big deal ;-)

Thank you so much!

Um abraço,
Henrique

Em 25 de maio de 2010 17:45, Hélio Guilherme escreveu:

Hi Henrique,

I believe that this does what you want:
loop for (n=6; n<=24; n*=2) --quiet

No other simple options.

On Tue, May 25, 2010 at 8:53 PM, Henrique Andrade wrote:
Dear Riccardo, Kehl and Artur,

Thanks a lot for your help! I'd tried all the options you gave me and
my final script looks like this:

<script>
scalar n=0
loop for (n=6;n<=24;n=n*2) --quiet
scalar m = \$T - n + 1
loop j=2..nelemY --quiet
matrix R\$n_\$j = zeros(m,1)
loop i=1..m --quiet
loop c=1..n --quiet
row = i + n - c
R\$n_\$j[i] += r\$j[row, c]
endloop
endloop
endloop
matrix mci\$n = R\$n_2 + R\$n_3
endloop
</script>

Now, because I just need the values for 6, 12 and 24, I'm trying to
substitute the second line "loop for (n=6;n<=24;n=n*2)" for this:

loop for (n=6;n=12;n=24)

But the script isn't working. Any hints?

Best regards,
Henrique

2010/5/25 artur bala

Or, if your index is something like of a geometric series as it seems to
be (let's say 6, 12, 24, 48, and so on) and too long to do manually
you can try this one:
<script>
scalar count=0
loop for (count=6;count<=24;count=count*2) --quiet
<instructions>
endloop
<\script>

cheers,
artur

Riccardo (Jack) Lucchetti a écrit :
> On Tue, 25 May 2010, Henrique Andrade wrote:
>
>> Dear Gretl Community,
>>
>> I'm trying to use a loop index inside a script but I don't know how.
>> According
>> to "Gretl User’s Guide" the syntax looks like this:
>>
>> loop i=1..24
>>
>> But I just need the points where "i" is equal to 6, 12 and 24.
>> Something like this:
>>
>> loop i=6;12;24
>>
>> How can I do that?
>
> For example, this way:
> <script>
> matrix foo = { 6, 12, 24 }
> n = cols(foo)
> loop for i=1..n
>     bar = foo[i]
>     print bar
> end loop
> </script>
>
>
> Riccardo (Jack) Lucchetti
> Dipartimento di Economia
> Università Politecnica delle Marche
>
> r.lucchetti@univpm.it
> http://www.econ.univpm.it/lucchetti
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gretl-users mailing list
> Gretl-users@lists.wfu.edu
> http://lists.wfu.edu/mailman/listinfo/gretl-users

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

--
Universidade Federal do Rio Grande do Sul
www.ufrgs.br/ppge

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

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

--