Replacement variable to replace various strings in loop
Posted: 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?
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?