Problem with loops

Scott Sampson (scott@znev03.desy.de)
Tue, 17 Mar 1998 14:47:04 +0100 (MET)


Hi,

I'm having a strange problem with loops. I convert an ntuple from PAW, run
the MakeCode, then edit the resulting .C file. I have a loop

for (Int_t i=0; i<nentries;i++) {
nbytes += h2->GetEvent(i);
Int_t isl;
for(isl=0;isl<fm_isl;isl=isl+1) {
if(Eis[isl]>0 && Isth[isl]>15 && Isth[isl]<30
&& Eem[isl]>0 && Ehac1[isl]>0 && Ehac2[isl]>0) {
cout << "begin if" << endl;
.
.
.
} cout << "endif" << endl;
} cout << "end event=" << i << endl;
}
Now, the funny thing is that sometimes the loop behaves as it should,
other times it seems to enter and leave the loop at different times. I
know this because I have cout statments at various places in the
code, and the one at the beginning of the loops is sometimes skipped.
i.e. When the loop end, the next executed statements is not at the
beginning of the loop (the first cout) but instead somewhere in the
middle. (If checked for coding mistakes like if I'm changing the "isl"
value inside the look somewhere) Why is this happening and is there a way
to fix it? Thanks,

Scott Sampson