Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 511

 
Juer:

An array of structures, I wrote...

Show the whole function you are trying to return something from

 
Artyom Trishkin:

Show the whole function you are trying to return something from

I wrote the function in a class above. Doesn't compile with errors invalid array access.

 
Juer:

I wrote the function in a class above. Doesn't compile with errors invalid array access.

What is the data type?

input_rule
 
Artyom Trishkin:

What is the data type?

This is my structure.

struct input_rule
  {    
   int                        candle_number;                // candle one order number
   int                        number;                       // rule number   
   bool                       enable;                       // rule enable status
   ENUM_DIR_TYPE              mode;                         // trade direction
   ENUM_CANDLE_TYPE           candle1_type;                 // candle 1 type
   ENUM_CANDLE_TYPE           candle2_type;                 // candle 2 type
   ...
  }
   
 
Juer:

This is my structure.

And you want to copy an array of such structures into another array of such structures?

 
Artyom Trishkin:

And you want to copy an array of such structures to another array of such structures?

Copy it, return it, or get it in any other way by calling the appropriate class method.

 
Juer:

Copy, return or otherwise retrieve it by calling the appropriate class method.

So, you have an array inside the class and you want to access it externally, right?

 
Artyom Trishkin:

So you have an array inside a class, and you want to access it externally, right?

Yes.

 
Juer:

Yes.

Have you tried that?

input_rule GetRulesArray() { return &rules; }
 
Artyom Trishkin:

Have you tried that?

Tried it - it doesn't compile

'rules' - invalid array access  CandleRule.mqh  163     12
'rules' - class type expected   CandleRule.mqh  163     12
'return' - object required      CandleRule.mqh  163     4
Reason: