Download MetaTrader 5
To add comments, please log in or register
MQL5 Cloud Network is a distributed computing network. Just give it a try!
Carl Schreiber
5927
Carl Schreiber 2014.03.23 14:09 

I defined a struct:

struct TradeStr {
        int Cnt;
        string TrdCat, Symb, Descr, Full, OrdCmt;
};

and in my EA I define a tmp-var of that:

TradeStr tmpStr;

If now the debugger is on its step by step mode comes to that line it jumps at the line of the definition of that struct and seems to to be able to leave it ...

Alain Verleyen
Moderator
28518
Alain Verleyen 2014.03.23 16:31  
gooly:

I defined a struct:

and in my EA I define a tmp-var of that:

If now the debugger is on its step by step mode comes to that line it jumps at the line of the definition of that struct and seems to to be able to leave it ...




I miss your point...where is the problem ?
Carl Schreiber
5927
Carl Schreiber 2014.03.23 21:37  

ok, try this:


struct TradeStr {
	int Magic;
	string TrdCat, NwsCur, Symb, Descr, Full, OrdCmt;
};
TradeStr ArrStr[];

struct TradeVal {
	double IniTgt, IniStp, LstTrl, StpLev,  
			 IniTrl,  IniLots, PTS, PIP, BuCheck, SeCheck,
			 BuTrl, SeTrl, BuHigh, SeLow, PrSlipp, TrdRisk,
			 LotStep, MinLot, MaxLot, BaseLot, MaxDD,
			 TckVal, TckSze, PntVal;
	datetime TmeOpn, TmeHi, TmeLo; 
	int Magic, DIG,  Mode, TrdCat, 
		 SeTckt, BuTckt, myIdx, Slipp; // 4 bytes 32 bit
	bool UseMM, UseHiLo, TrdSet; // 1 byte
};
TradeVal ArrVal[];


int OnInit()
//int init()
  {
//---
   int a = 1;
	TradeStr tmpE;
	ArrayResize(ArrVal,100);
	TradeVal tmpA;
	ArrayResize(ArrStr,100);
	TradeStr tmpF;
//---
   return(INIT_SUCCEEDED);
  }

I would expect the debugger-behaviour of ArrayResize(ArrStr,100); to be the same as ArrayResize(ArrVal,100); (1 step of F11).

Gooly

Carl Schreiber
5927
Carl Schreiber 2014.03.24 12:01  
The debugger button Shift-F11 "junp out of the function" doesn't work as well as it not a function..
Alain Verleyen
Moderator
28518
Alain Verleyen 2014.03.24 14:30  
gooly:

ok, try this:

I would expect the debugger-behaviour of ArrayResize(ArrStr,100); to be the same as ArrayResize(ArrVal,100); (1 step of F11).

Gooly


Ok I see. The problem is that your struct with a string is automatically assigned a constructor, see documentation :

If a structure contains variables of the string type and/or object of a dynamic array, the compiler assigns an implicit constructor to such a structure. This constructor resets all the structure members of string type and correctly initializes objects of the dynamic array.

So the constructor is called for the 100 elements of your array.

You can use F10 to step over this.

Carl Schreiber
5927
Carl Schreiber 2014.03.24 15:28  

I have read the reverence I think too that it this might be the reason - but despite that:

1) the explanation can't explain both: step in like into a user-function but Shift-F11 'steps' out of the user-function where ArrayResize is placed - not just the 'trap'.

2) If you accidentally have missed to step over you are trapped and Shift-F11 puts you where you don't want to be :(

Gooly

Alain Verleyen
Moderator
28518
Alain Verleyen 2014.03.24 15:36  
gooly:

I have read the reverence I think too that it this might be the reason - but despite that:

1) the explanation can't explain both: step in like into a user-function but Shift-F11 'steps' out of the user-function where ArrayResize is placed - not just the 'trap'.

2) If you accidentally have missed to step over you are trapped and Shift-F11 puts you where you don't want to be :(

Gooly

If you are trapped you can place a new breakpoint on the line following the call then press F5.
/
To add comments, please log in or register