OOP, templates and macros in mql5, subtleties and uses - page 23

 
Igor Makanu:

so I can do what I want.


interested in options suggested yesterday using the magic spell #defaine abracadabra ##_

UPD:

Vladimir Simakov OK, I'll try to figure it out

Igor Makanu:

so do what I want


interested in the variations suggested yesterday using the magic spell #defaine abracadabra ##_

UPD:

Vladimir Simakov OK, I will try to figure it out

UPD:

HOORAY! IT WORKED! (С)


Thank you! It worked as intended!


PZY: How would I add __MQL5__ and __MQL4__ macros to this abracadabra, but fast_xxx() functions will never be in MQL4 code at all - from the word NEVER

UPD:

HOORAY! IT WORKED! (С)


Thanks! It took off as planned!


PZY: How would I add __MQL5__ and __MQL4__ macros to this abracadabra but fast_xxx() functions will never be in MQL4 code at all - from the word NEVER

#ifdef __MQL5__
   #ifdef  USE_FAST
      #define  CONNECT fast_connect
   #else
      #define  CONNECT connect
   #endif
#else
   #define  CONNECT connect
#endif
 

how do I know which terminal (MT4/MT5) is executing the code?

one true/false variable is enough

 
Igor Makanu:

how do I know which terminal (MT4/MT5) is executing the code?

one true/false variable is enough

bool is_mt5=(TerminalInfoString(TERMINAL_NAME)=="MetaTrader 5");
 
Artyom Trishkin:

OK, but I want to look in the macros, it's likely to be something simple.

UPD:

#ifdef __MQL5__
  #define  mql5 true
#else
  #define  mql5 false 
#endif

bool isMQL5 = mql5;
 
Igor Makanu:

OK, but I want to look in the macros, it's likely to be something simple.

UPD:

What's the sacred meaning?

 
Artyom Trishkin:

What is the sacred meaning?

check the compiler, if it is the "right compiler", it should throw out everything unnecessary at the compile stage

#ifdef __MQL5__
  #define  mql5 true
#else
  #define  mql5 false 
#endif

const bool isMQL5 = mql5;

const string txt_1000symbols = "Язык MetaQuotes Language 5 (MQL5) является объектно-ориентированным языком программирования высокого уровня и предназначен для написания"
                               "автоматических торговых стратегий, пользовательских технических индикаторов для анализа разнообразных финансовых рынков. Он позволяет не только писать разнообразные"
                               "экспертные системы, предназначенные для работы в режиме реального времени, но и создавать собственные графические инструменты, помогающие принимать торговые решения."
                               "MQL5 основан на концепции широко распространенного языка программирования С++, по сравнению с MQL4 в нем добавлены перечисления, структуры, классы и обработка событий."
                               " Благодаря расширению числа встроенных основных типов, взаимодействие исполняемых программ на MQL5 с другими приложениями "
                               "посредством dll максимально облегчено. Синтаксис языка MQL5 подобен синтаксису С++, и это позволяет легко переносить на него программы из современных языков "
                               "программирования. Для целей изучения языка все темы сгруппированы по следующим разделам.\n";
//+------------------------------------------------------------------+
void OnStart()
  {
   if(isMQL5) Print(txt_1000symbols);
   Print("end");
  }
//+------------------------------------------------------------------+

compile it and watch the size of .ex5 ;)

SZY: in if() you can putisMQL5 ,mql5 , you can remove const modifier - in general, it is a correct compiler.

 

there is such a code:

#import "mydll.dll"
#import

mt4 does not create new copies of dll in memory if called from 2 EA, I do not want to edit the dll itself (it is 100 % satisfactory), it is easier to copy mydll.dll file 5 times

I need to macro to get the following

#define  dllnum 02

#import "mydll02.dll"
#import

But I want to check that if there is no macro,dllnum then it will be "mydll.dll"



UPD:

this solved

#define  dllnum 2

#define  DEF_QUOTES(arg) #arg

#ifdef  dllnum
   #define  DEF_DLL_NAME(a,b) DEF_QUOTES(a##0##b.dll)
#else
   #define  DEF_DLL_NAME(a,b) DEF_QUOTES(a.dll)
#endif 

   
string s =  DEF_DLL_NAME(mydll,dllnum);


UPD2: not solved (((.

'mydll02.dll' - expressions are not allowed on a global scope

 
Igor Makanu:

there is such a code:

mt4 does not create new copies of dll in memory if called from 2 EA, I do not want to edit the dll itself (it is 100 % satisfactory), it is easier to copy mydll.dll file 5 times

I need to macro to get the following

But I want to check that if there is no macro,dllnum then it will be "mydll.dll"



UPD:

this solved


UPD2: not solved (((.

'mydll02.dll' - expressions are not allowed on a global scope

It won't work, I guess.

DEF_QUOTES(a##0##b.dll)

It doesn't get a valid token here. Generally, mcl should be able to

#import "jkjfkj"".dll"

but alas, as they say - you're not here with C++))

 
Vict:

It won't work, I guess.

it doesn't get a valid token here. Actually, the mcl should be able to

but alas, as they say - this is not C++))

mm-hmm

at least i tried to macroinclude the tokens.... it went wrong again

#define  FNAME <mylib.mqh>

#include  FNAME

'#include' - double quotes or angle bracket < are needed

'#include' - expressions are not allowed on a global scope


 
Igor Makanu:

Just don't get it - what are the candles burning for? That's how it works, I guess:

#define  LIB "kjkjkjk.dll"
#import  LIB

I admit that it may be useful when there is some config that is being corrected.

PS: if you still really want to, try name_dll (without dot), maybe it will take off.