OOP, templates and macros in mql5, subtleties and uses - page 17
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Do macros return values?
Well, here is a code example
Here is a code example
Macro substitution means that all that code (which is in the define), will be substituted every time in a specified place in the program. So in fact, instead of making a function and calling it, you copy this function inside the code many times, as a piece of code.
And if you makereturn from a macro, it isreturn from all the code where this macro is inserted.
macro substitution means that all the code (which is in the define), will be substituted each time in the specified place of the program. In fact, instead of making a function and calling it, you copy this function inside the code many times, as a piece of code.
And if you makereturn from a macro, this is return from the whole code where this macro is inserted.
It turns out that you cannot write a macro function.
It turns out that there is no way to write a macro function.
A macro substitution is replacing one text with another (in the source code), it cannot be a function by definition.
How to write 2 macros without jumping to a new line it greatly increases the number of lines, which greatly lengthens the program, here is an example
Macro B does not work anymore.
is it possible to convert a variable name into a string?
It doesn't work that way:
Guys, I want to write a macro of makros(a) and it will work like this: if a equals 1, it will return any value of int type, if a equals 2, it will return any value of double type, if a equals 3, it will return any value of bool type. Is it possible to do this?
What for? What for? Where are you going to use it?
is it possible to convert a variable name into a string?
Guys this question I want to write a macro makros(a), it will work like this: if a is equal to 1ce then the macro will return any value of type int, if a is equal to 2ke then the macro will return any value of type double, if a is equal to 3ke then the macro will return any value of type bool. Is it possible to do this?
In µl, you can do without GET_EXPAND, but it's µl-specific stuff, it's more correct. Well, μl macros are very limited due to lack of comma operator (although through crutches ...).
ZZY: and it's all compile time, of course.
ZZZY: by the way, if there was a ghost operator, you could do this: