For loop problem
Posted: Tue Sep 10, 2013 2:36 am
The code below only loops through the first variable in the outer loop. The outer loop uses only "TSTI" and "PS1" and not "TSTII" and "PS2". If I copy and past the commands and use TSTI and PS1 in the copied paragraph and TSTII and PS2 in the pastet paragraph, it works. I don't see why the loop shouldn't do the same. Sorry for the long batch. It is all a part of a large batch file.
Code: Select all
series PS1
series PS2
group gr2 TSTI TSTII ' the variable names
group gr6 PS1 PS2 'scenario alias
!ngr2 = gr2.@count
for !i = 1 to !ngr2
%str6 = gr6.@seriesname(!i)
%str2 = gr2.@seriesname(!i)
SERIES {%str2}_{%str6} = {%str2}
SMPL 2012q3 2017q4
SERIES {%str2}_{%str6} = {%str2}*0.5
MOD_2SLS.SCENARIO(N, A=_{%str6}) "SCENARIO" {%str6}
MOD_2SLS.OVERRIDE {%str2}
MOD_2SLS.SCENARIO(C) "BASELINE"
MOD_2SLS.SOLVEOPT(M=5000, S=A, D=D, R=1000, B=0.95, A=T, O=G, CU=T)
MOD_2SLS.SOLVE
group gr1 AB AC AD AE AF AG AH AI AJ AK AL AM AN AO AP AQ AR AS AT AU
!n1 = gr1.@count
for !i=1 to !n1
%str1 = gr1.@seriesname(!i)
MOD_2SLS.MAKEGRAPH( c, S=m, G=v) GRAPH_{%str2}_{%str1} {%str1}
next
group gr3 AB AC AD AE AF AG AH AI AJ AK AL AM AN AO AP AQ AR AS AT AU
group gr4 "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20"
!n1 = gr3.@count
for !i=1 to !n1
%str3 = gr3.@seriesname(!i)
%str4 = gr4.@seriesname(!i)
graph_{%str2}_{%str3}.legend -display
graph_{%str2}_{%str3}.addtext(t) {%str4}
next
group gr5 AB AC AD AE AF
!n1 = gr5.@count
%grnames = ""
for !loop = 1 to !n1
%grnames = %grnames + " " + "graph_" + %str2 + "_" + gr5.@seriesname(!loop)
next
graph graph_{%str2}_{%date}.merge {%grnames}
graph_{%str2}_{%date}.axis(l) grid zeroline
graph_{%str2}_{%date}.axis(b) grid
graph_{%str2}_{%date}.addtext(t, x, font("Arial",24,+b,+i),just(c)) Stress {%str2} {%datelong}\r Stress values are blue, baseline values are green
show graph_{%str2}_{%date}.align(4,1,1)
next