[Gretl-users] indexes in loops
Allin Cottrell
cottrell at wfu.edu
Thu Sep 7 10:23:39 EDT 2006
On Thu, 7 Sep 2006, Arnaud Bervas wrote:
> Thanks for your suggestion, but it doesn't seem to work with
> my script. It doesn't seem possible to make Gretl recognize
> j=i+1 or $j =$i+1 as a new index...
Please show a little piece of script that demonstrates the
problem.
Looking at the above, the second variant will surely not work,
for this reason: when you use the "$" form of a loop control
variable, it works by "string substitution". Before the command
line is parsed, all occurrences of "$i" are replaced by the
current numerical value of i. This allows you to use "$i" in
string contexts such as variable names:
genr foo$i = ...
But it means that in "$j =$i+1", you are trying to assign a
value to a numeric constant on the left-hand side, as in
3 = 10+1
Allin.
More information about the Gretl-users
mailing list