How to define the filename to be included later?

 

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?

 
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
 
Lorentzos Roussos #:

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

In that case you can gate it with 

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

That will not work, you can't use #define with #include.
 

got it!

Thanks.

Already redesigned my file structure and the includes.