Struct arrays not allowed?

 

Well, If you put the following code into a script and load it up on a chart, you won't get the correct time value.  Why?

int start()
  {
   struct OrderInfo
     {
       datetime dOpen[];
     };
   OrderInfo myOrder;
   int OrderCount=0;
   myOrder.dOpen[OrderCount]=Time[2];
   Comment(TimeToString(myOrder.dOpen[OrderCount],TIME_DATE|TIME_MINUTES));
   return(0);
  }
I'm running similar code in another script and get array out range errors.  I'm thinking they're related.
 
nondisclosure:

Well, If you put the following code into a script and load it up on a chart, you won't get the correct time value.  Why?

I'm running similar code in another script and get array out range errors.  I'm thinking they're related.

 


I assume your other code initializes the array first, or specifies the array size in declaration.
 

First you miss to ArrayResize(dOpen,..) as DeepThought said!

But I would use this way:

struct OrderInfo{
    datetime dOpen;
    // ...
};
OrderInfo ArrOrdInf[];
..
ArrayResize(ArrOrdInf,..);
...

Gooly

 

Thanks everyone.  The stroke had me posting the question before implementing the correct way.

Reason: