ArrayResize declaration without type

 

This code's error is 'declaration without type', Any idea why and how to fix it? Thanks


input int       days=3;

Session *session[];
ArrayResize(session, days); //<<<< ERROR <<< declaration without type.
 

You have to specify the datatype of the array.

Is it long, int, double, string, datetime ?

The compiler isn't good at guessing.

 
Marco vd Heijden:

You have to specify the datatype of the array.

Is it long, int, double, string, datetime ?

The compiler isn't good at guessing.

Why the docs then does not specify the datatype in their example

https://www.mql5.com/en/docs/array/arrayresize

Can you give the solution for this case in the code please?

Thanks

Documentation on MQL5: Array Functions / ArrayResize
Documentation on MQL5: Array Functions / ArrayResize
  • www.mql5.com
If ArrayResize() is applied to a static array, a timeseries or an indicator buffer, the array size remains the same – these arrays will not be reallocated. In this case, if The function can be applied only to dynamic arrays. It should be noted that you cannot change the size of dynamic arrays assigned as indicator buffers by the...
 
samjesse:

Why the docs then does not specify the datatype in their example

https://www.mql5.com/en/docs/array/arrayresize

Can you give the solution for this case in the code please?

Thanks

ArrayResize() can't be on global scope.

 
Alain Verleyen:

ArrayResize() can't be on global scope.

Thank you.

 
samjesse:

This code's error is 'declaration without type', Any idea why and how to fix it? Thanks


Do not double post. It is annoying and can waste people's time.

I have deleted your other post

 
samjesse:

This code's error is 'declaration without type', Any idea why and how to fix it? Thanks

input int       days=3;

class Session;

Session *session[];
const int Init = ArrayResize(session, days); // OK
 
fxsaber:
Useless.
 
Alain Verleyen:
Useless.

You just do not understand.

 
fxsaber:

You just do not understand.

Of course, I don't understand anything from you. :-)

Are you answering to help people or ... ? Please explain us what can be the usage of using ArrayResize() on the global scope using a "const int" ?

 
Alain Verleyen:

Of course, I don't understand anything from you. :-)

Are you answering to help people or ... ? Please explain us what can be the usage of using ArrayResize() on the global scope using a "const int" ?

Run

input int       days=3;

class Session
{
public:
  Session() { Print(__FUNCSIG__); }
};

Session session[];
const int Init = ArrayResize(session, days); // OK

int OnInit()
{
  Print(__FUNCSIG__);
  
  return(INIT_FAILED);
}


Result

void Session::Session()
void Session::Session()
void Session::Session()
int OnInit()


ArrayResize before OnInit. This is useful, for example, here.

Init_Sync
Init_Sync
  • www.mql5.com
If you change the timeframe or the name of the chart symbol in MetaTrader, all indicators on the chart will be unloaded from the chart and will be loaded onto it again. Unlike MT4, in MT5 the sequence of load/unload is not defined due to its internal architecture. This feature sometimes causes problems which are not immediately obvious. These...
Reason: