Page 1 of 1

Access table cells with variables

Posted: Mon Nov 24, 2008 10:08 am
by cap
Hello,

I would like to access certain cells inside a table using variable indices. For example, to print numbers down the 2nd column, I thought this would work:

______________________
table mytable

for !i=1 to !i=5
regout(2,!i)=!i
next

______________________


But, this did not work, and after running the program I get no error messages...


Thanks in advance,
-cap

Re: Access table cells with variables

Posted: Mon Nov 24, 2008 10:13 am
by EViews Gareth
What's regout?

Re: Access table cells with variables

Posted: Mon Nov 24, 2008 11:40 am
by cap
Sorry, its just the name of the same table, I meant to edit my code as follows:


______________________
table mytable

for !i=1 to !i=5
mytable(2,!i)=!i
next

______________________

Any help would still be appreciated, thanks,
-cap

Re: Access table cells with variables

Posted: Mon Nov 24, 2008 12:07 pm
by cap
Ok, it seems now that the code does actually work, but now I can not use the loop variable in computations. For example, when I assign a cell the value !i+10, it still only puts in the value !i.

___________________________
table mytable

for !i=1 to !i=5
mytable(1,!i)=!i+10
next

___________________________


Any ideas?

-cap

Re: Access table cells with variables

Posted: Mon Nov 24, 2008 2:14 pm
by EViews Gareth
You have the syntax of the for loop incorrect.

Your code should be:

Code: Select all

for !i=1 to 5 mytable(1,!i)=!i+10 next

Re: Access table cells with variables

Posted: Mon Nov 24, 2008 2:41 pm
by cap
Ah, sorry, dumb question, thanks very much though.

-cap