How to define the filename to be included later?

Eugen Funk  

Hi, I would like to do the following:


EA.mq5


#define FILE_TO_INCLUDE "Env1.mqh"

#include "Body.mqh"



Body.mqh


<... som stuff ... >


#include FILE_TO_INCLUDE


Its not working right away -- is that possible with some trick?

Lorentzos Roussos  
Eugen Funk:

Hi, I would like to do the following:


EA.mq5





Body.mqh




Its not working right away -- is that possible with some trick?

If there is no file definition it should not work right ? 

In that case you can gate it with 

#ifdef FILE_TO_INCLUDE
#include FILE_TO_INCLUDE
#endif

https://www.mql5.com/en/docs/basis/preprosessor/conditional_compilation

Documentation on MQL5: Language Basics / Preprocessor / Conditional Compilation (#ifdef, #ifndef, #else, #endif)
Documentation on MQL5: Language Basics / Preprocessor / Conditional Compilation (#ifdef, #ifndef, #else, #endif)
  • www.mql5.com
Conditional Compilation (#ifdef, #ifndef, #else, #endif) - Preprocessor - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Eugen Funk  

got it!

Thanks.

Already redesigned my file structure and the includes.

Reason: