Control Variables already defined in nested FOR loop
Posted: Wed Oct 30, 2013 3:32 am
Hi, sorry if someone has posted a topic about this already. I've written the following loop:
where port1_test1 etc are pre-defined string variables containing the file name and path of previously saved workfiles.
The problem I'm having is that when the code runs the final iteration of the 3rd loop, it tries to run it again, replacing the control variable %series with econ3 and so the program falls over.
I've tried resetting %series="" at the end of the loop but that causes a similar error.
Hope I've explained my problem well. Any ideas??
Code: Select all
%series_list = "econ1 econ2 econ3"
For %portfolio port1 port2 port3
For %model test1 test2 test3 test4
%temp= "%" + %portfolio + "_" + %model
wfopen {%temp}
%current_wf1=@wfname
For %series {%series_list}
Pageselect New_Port
if @isobject(%series)=1 then
copy(overwrite) {%current_wf1}::New_Port\{%series} {%wf1_name}::Economics\{%series}_{%portfolio}_{%model}
else
statusline %series does not exist in workfile %temp
endif
next
wfuse {%current_wf1}
wfclose
next
next
The problem I'm having is that when the code runs the final iteration of the 3rd loop, it tries to run it again, replacing the control variable %series with econ3 and so the program falls over.
I've tried resetting %series="" at the end of the loop but that causes a similar error.
Hope I've explained my problem well. Any ideas??