Problem with arrays - page 2

 
WHRoeder:
In 2009.10 I had coded:

And it wouldn't compile; said something like array index must be an integer.

Perhaps my comment is no long true.

No, it's still true. Raptor evidently tried it - and so did I :-)

The error message was included in Raptor's earlier post.

 
PFUNK:
Am missing something really basic…

YES!


test script ...

int myArray[20];

int start(){

   myArray[10]={2};  // this is not how you assign a value; it can only be used as an initialiser list
   //myArray[10]= 2; // this is the correct assignment
   
   Comment("my array 10 is " + myArray[10]);

   return(0);
}
 

PFUNK:
Ok, So I've lost the OrdersHistoryTotal(); … but still getting 0 on Alert ouput. Am missing something really basic…

I have a question for you,just to clarify.... is this really what you want to do ?

Create an array and use the array element with the index equal to the amount of closed orders ?

example:

Total amount of closed orders returned by OrdersHistoryTotal() is 500

Therefore use the array element: myarray[500]

Then assign to that array element the value: 11

The reason I ask, that is what your original code was attempting to do I was just wondering if that really was the intention ....

Reason: