Ed,
Thanks for the info about attachments. I've only just started
using
this forum.
Without seeing where you've put the trace
statements for i & j, it's a
bit hard to comment on your
test.
However, if I run the following code, using a wait period of 5 to
make
it shorter:
waitPeriod = 5;
Setup2 = ExRemSpan(1,
waitPeriod-1);
Setup = 1;
for (i = 0; i < BarCount - waitPeriod;
i++) {
if (Setup[ i ]) {
for (j = i + 1; j < i + waitPeriod; j++)
{
Setup[ j ] = 0;
}
i = j;
}
}
for (i = 0; i < BarCount;
i++)
_TRACE(StrFormat("%1.0f - %1.0f", Setup[i],
Setup2[i]));
The loop code is the same as Bernard posted from your
original
message, I've just added the ExRemSpan alternative as a
comparison
then traced the output.
The results start off like
this:
1 - 1
0 - 0
0 - 0
0 - 0
0 - 0
1 - 1
1 - 0
0
- 0
0 - 0
0 - 0
0 - 1
1 - 0
1 - 0
0 - 0
0 - 0
0 -
1
0 - 0
1 - 0
1 - 0
0 - 0
The ExRemSpan function correctly
(by my interpretation of the
requirement) gives a one followed by four
zeroes repeated throughout
the array. However, the loop code skips one bar,
giving two ones at
the end of each block of four zeros, make the repeat
length six rather
than five.
Also, the end of the array looks like
this:
0 - 1
0 - 0
0 - 0
1 - 0
1 - 0
0 - 1
0 - 0
0
- 0
0 - 0
1 - 0
1 - 1
1 - 0
1 - 0
1 - 0
The loop code
hasn't continued right to the end of the array. The
changes I suggested fix
both issues, making the loop identical to the
ExRemSpan
function.
The potential overflow of the j loop is only if the code is
changed to
the correction I mentioned. It won't happen with the original
code.
Regards,
GP