Build 600 #Property no longer works in include files

 

In the Build 600 MQL4 Reference it says "Properties described in included files are completely ignored. Properties must be specified in the main mq4-file." They are talking about the #property statement.

It was allowed in Build 509 but not anymore!!!!

How are we supposed to know this? MetaQuotes change the functionality of the language and expect us to know what they changed? Where can I go to see what has changed in the language from Build509 to Build600? Anybody know the answer? I stumbled on the #property change only after trying to debug why my application was no longer working.

 
Hillderek:

In the Build 600 MQL4 Reference it says "Properties described in included files are completely ignored. Properties must be specified in the main mq4-file." They are talking about the #property statement.

It was allowed in Build 509 but not anymore!!!!

How are we supposed to know this? MetaQuotes change the functionality of the language and expect us to know what they changed? Where can I go to see what has changed in the language from Build509 to Build600? Anybody know the answer? I stumbled on the #property change only after trying to debug why my application was no longer working.

Attach the code you're having problems with.
 

Here is the code in the form of a simple test case. This code can be used to create an empty sub-window into which you can place whatever you want later on. My actual indicator is much more than this and I had my reasons for putting the #property statement into the include file, which it is not necessary to explain in order to illustrate the problem I am talking about:

TestSubWindow.mq4 indicator file:

#include <TestInclude.mqh>

TestInclude.mqh file:

#property indicator_separate_window
int init() { return(0);}
int deinit(){ return(0);}
int start() { return(0);}

Compile TestSubWindow. There are No error messages, not even a warning message from the compiler. When you run it the indicator has no label in top LH corner which should say "TestSubWindow", and the scale on RH side of window is missing. Now try and drop a vertical line from the 'Line Studies' toolbars into the window - it does not take.

If you move the #property statement out of the include file and into the main mq4 file and recompile, then everything works fine.

 
Hillderek:

Here is the code in the form of a simple test case. This code can be used to create an empty sub-window into which you can place whatever you want later on. My actual indicator is much more than this and I had my reasons for putting the #property statement into the include file, which it is not necessary to explain in order to illustrate the problem I am talking about:

TestSubWindow.mq4 indicator file:

#include <TestInclude.mqh>

TestInclude.mqh file:

#property indicator_separate_window
int init() { return(0);}
int deinit(){ return(0);}
int start() { return(0);}

Compile TestSubWindow. There are No error messages, not even a warning message from the compiler. When you run it the indicator has no label in top LH corner which should say "TestSubWindow", and the scale on RH side of window is missing. Now try and drop a vertical line from the 'Line Studies' toolbars into the window - it does not take.

If you move the #property statement out of the include file and into the main mq4 file and recompile, then everything works fine.

It appears to be a behavior which is being phased out of mql4+. You could try keeping a copy of the old compiler to retain this behavior. The above is consistent with the expectation set forth for this new built. Personally, I never taught it made much sense having a #Property Library in the include file treating my Expert Advisor like a Library because I included it. If you believe it's a bug || want to keep this feature then contact metaQuotes via the service desk. The new mql4+ would hopefully implement the ability to include indicators as Services just like in mt5. That way it's all bundled within a single file. If that helps at all.

 

I am not sure, if "completely ignored" is correct. At least #property strict is not ignored, if placed only within the include file.

I understand, that many properties, like #property copyright, conflict and must be treated by some rule, but I do not understand why declarations should get "completely ignored" when in the include file.

Btw, what is not mentioned in the Documentation is, that #include xxx.mqh works only once on a particular include file; which is fine, but should have been mentioned in docs.

 
Hillderek:

Here is the code in the form of a simple test case. This code can be used to create an empty sub-window into which you can place whatever you want later on. My actual indicator is much more than this and I had my reasons for putting the #property statement into the include file, which it is not necessary to explain in order to illustrate the problem I am talking about:

TestSubWindow.mq4 indicator file:

#include <TestInclude.mqh>

TestInclude.mqh file:

#property indicator_separate_window
int init() { return(0);}
int deinit(){ return(0);}
int start() { return(0);}

Compile TestSubWindow. There are No error messages, not even a warning message from the compiler. When you run it the indicator has no label in top LH corner which should say "TestSubWindow", and the scale on RH side of window is missing. Now try and drop a vertical line from the 'Line Studies' toolbars into the window - it does not take.

If you move the #property statement out of the include file and into the main mq4 file and recompile, then everything works fine.

Reported to ServiceDesk, please be patient.
 
Hillderek:

I am talking about:

TestSubWindow.mq4 indicator file:

#include <TestInclude.mqh>

TestInclude.mqh file:

#property indicator_separate_window
int init() { return(0);}
int deinit(){ return(0);}
int start() { return(0);}

Compile TestSubWindow. There are No error messages, not even a warning message from the compiler. When you run it the indicator has no label in top LH corner which should say "TestSubWindow", and the scale on RH side of window is missing. Now try and drop a vertical line from the 'Line Studies' toolbars into the window - it does not take.

If you move the #property statement out of the include file and into the main mq4 file and recompile, then everything works fine.

Are you sure that such directives must be in include files? I am in doubt about it.
 
Well it worked fine in Build 509. I do it this way because I don't like duplicating any coding if I can avoid it. The include file gets called by more than one main indicator, so I put the #property statement in the include file once, instead of in multiple main indicator files. It's how I do things.
 

Program Properties (#property)

Every mql4-program allows to specify additional specific parameters named #property that help client terminal in proper servicing for programs without the necessity to launch them explicitly. This concerns external settings of indicators, first of all. Properties described in included files are completely ignored. Properties must be specified in the main mq4-file.

 
SDC:

Program Properties (#property)

Every mql4-program allows to specify additional specific parameters named #property that help client terminal in proper servicing for programs without the necessity to launch them explicitly. This concerns external settings of indicators, first of all. Properties described in included files are completely ignored. Properties must be specified in the main mq4-file.

From here: https://docs.mql4.com/en/basis/preprosessor/compilation
 
I have multiple-level include and the #property strict is submerged in the deepest level file. It definitively applies to the entire source code.
Reason: