Forum on trading, automated trading systems and testing trading strategies
How to write a function like Print(...)
William Roeder, 2022.12.02 13:46
There are no variadic functions.
See the following:
Define Variadic Arguments in Functions? - Bollinger Bands, BB - Expert Advisors and Automated Trading - MQL5 programming forum (2018)
Function with variable number of parameters - MQL4 programming forum (2018)
Different Indicators Parameters to iCustom - MQL5 programming forum (2020)
Hello all
I want to write a function like this:
But I don't know what argument I should pass to myPrint() function instead of ...args which support all data types
Thanks in advance
If the purpose is to have control over the printing across compilations , for debugging , you could as well send the string as you would format it for Print()
So if you had :
Print("Ticket is "+IntegerToString(ticket));
you do :
DebugPrint("Ticket is "+IntegerToString(ticket));
and the DebugPrint has the print switch internally which is defined on top of your code.
Furthermore , in later or past projects you just throw the DebugPrint function in , set the define and replace all Prints with DebugPrints (via the find window)
If the purpose is to have control over the printing across compilations , for debugging , you could as well send the string as you would format it for Print()
So if you had :
you do :
and the DebugPrint has the print switch internally which is defined on top of your code.
Furthermore , in later or past projects you just throw the DebugPrint function in , set the define and replace all Prints with DebugPrints (via the find window)
It was useful. Thanks 🙂
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello all
I want to write a function like this:
But I don't know what argument I should pass to myPrint() function instead of ...args which support all data types
Thanks in advance