Replacement variable to replace various strings in loop

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

raphbrun
Posts: 8
Joined: Thu Feb 26, 2009 3:36 am

Replacement variable to replace various strings in loop

Postby raphbrun » Fri Jul 09, 2010 3:37 pm

I have a program where the same loop is coming at various occasions:

for %y fr us uk

If I then need to change my loop, e.g. replace "for %y fr us uk" by "for %y fr us", I will have to do so every time the loop is coming in the program. Ideally, I would like to make only one change and see this change reflected in all the loops. I am thinking of replacing the content of the loop by a replacement variable to be defined at the start of the program but the way I do it does not work:

%loop = "%y " + "fr " + "us " + "uk"
for %loop
scalar s_{%y}=1
next

The following does not work neither:

%loop = "%y " + "fr " + "us " + "uk"
for {%loop}
scalar s_{%y}=1
next

I guess this is an important question while programing. Any idea?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13586
Joined: Tue Sep 16, 2008 5:38 pm

Re: Replacement variable to replace various strings in loop

Postby EViews Gareth » Fri Jul 09, 2010 4:16 pm

Code: Select all

%loop = "fr " + "us " + "uk" for %y {%loop} scalar s_{%y}=1 next

raphbrun
Posts: 8
Joined: Thu Feb 26, 2009 3:36 am

Re: Replacement variable to replace various strings in loop

Postby raphbrun » Mon Jul 12, 2010 10:57 am

Thanks

Your reply makes sense and must be correct but I guess it is only be valid on later versions of Eviews. I have tried it on Eviews 5 and it does not work.I am aware Eviews 7 has made progress with strings and I suppose your code must be working on the latest version.

Thanks again

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Replacement variable to replace various strings in loop

Postby EViews Glenn » Mon Jul 12, 2010 11:23 am

The replacement of the loop strings is a version 7 feature.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests