Actually...hold on. I posted two versions of the code (one with arrays,
and one with static variables) and *both* versions do not capture all
the numbers in the text file.
As mentioned, the following version only sees less than 3,000 numbers
even though the text file contains 5000. And it uses dynamically named
static variables. What is wrong with this code?
Count = 0;
if(Status("ActionEx") == actionExOptimizeSetup)
{
count = 0;
fh = fopen("c:\\TestExtractFile03.txt", "r");
if (fh)
{
while(!feof(fh))
{
StaticVarSet("Row"+NumToStr(Count,1.0,0), StrToNum(fgets(fh)) );
StaticVarSet("Count", Count);
Count++;
}
fclose( fh );
} else
{
printf("ERROR: file can not be found (does not exist)");
}
}
b = Optimize("b", 9, 1, Count, 1);
Count = StaticVarGet("Count");
for(a = 0; a < Count; a++)
{
Row = StaticVarGet("Row"+NumToStr(a,1.0,0));
printf("Row: %g\n", Row );
}
Buy = a == 12; // random buy/sell conditions for test purposes
Sell = a == 2;
--- In [email protected], "ozzyapeman" <[EMAIL PROTECTED]> wrote:
>
> Ah! That must be it. I was confused why I was sometimes seeing
> subscript out of range errors based on barcount, even though I was not
> actually referencing any bars. I didn't realize that even non-bar
> based arrays are also limited to barcount. Kinda weird that such would
> be the case, but guess it's one of the quirks.
>