Errors, bugs, questions - page 2353

 
Alexey Navoykov:
Where have you seen text handles? ) And if we complicate things, handles can also be specified as a structure.
Yes... and so on:
struct A { int i; };
bool SelectHandle( A& ) { return true; }
A GetHandle() { A a; return a; }
A NewHandle;
datetime time = MACRO100( NewHandle, TimeCurrent());

also works

 
A100:
Yes... and so on:

also works

There's still an array ) And it has to be made into a byte array first, and then converted into a structure using the proprietary TypeToBytes library )

 
Alexey Navoykov:

There's still an array left ) And it has to be made into an array of bytes first, and then converted into a structure using the proprietary TypeToBytes library )

Can't check it - I have no such library file (build 1961x32). In a week you'll be able to see for yourself

 
Alexey Navoykov:
Where have you seen text handles? ) And if we complicate the conditions, the handles can also be specified as a structure.

Please give me a link to the task.
Thank you.

 
Sergey Dzyublik:

Please give me a link to the task.
Thank you.

https://www.mql5.com/ru/forum/1111/page2350#comment_9974834

 

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

pavlick_, 2018.12.21 17:23

int MACROS_helper_PrevHandle;
datetime MACROS_helper_time;
#define  MACROS(NEW_HANDLE_, FN_)   (MACROS_helper_PrevHandle=GetHandle())*0 == 0 ?  \
                                     (MACROS_helper_time=SelectHandle(NEW_HANDLE_) ? FN_ : 0)*0 == 0 ? \
                                        SelectHandle(MACROS_helper_PrevHandle)*0 == 0 ? MACROS_helper_time : 0 : 0 : 0
Unfortunately, this variant refers to
Alexey Navoykov:
global variable to use.


I have not thought about this problem too much. I have not found a solution right away, so I decided to learn on this forum. I'm not interested in intrigue, because I want to use it in practice - Virtual-bibble, without which I cannot imagine a combat EA anymore.

Well, as two people have already stated that there is a solution without additional variables, I will try it at the weekend.

Let me specify that NewHandle can be a constant. I.e. a valid call.

time = MACROS(0, TimeCurrent()); // TimeCurrent из 0-хендла.
time = MACROS(1, TimeCurrent()); // TimeCurrent из 1-хендла.

MACROS(0, SymbolInfoTick(_Symbol, Tick)); // SymbolInfoTick из 0-хендла.

#define Bid SymbolInfoDouble(_Symbol, SYMBOL_BID)
Price = MACROS(3, Bid); // Bid из 3-хендла.
 

fxsaber:

NewHandle can be a constant. I.e. a valid call like this

Everything works:

#include "Простейшее.mqh"
 int GetHandle() { return 0; }
bool SelectHandle( int ) { return true; }
#define Bid SymbolInfoDouble(_Symbol, SYMBOL_BID)
void OnStart()
{
        datetime time = MACRO100(0, TimeCurrent());
                 time = MACRO100(1, TimeCurrent());
        MqlTick tick;
        MACRO100(0, SymbolInfoTick(_Symbol, tick));
        double price = MACRO100(3, Bid);
}

When else will the opportunity arise... to check the real level
Judging by the discussions... here... serious proggers cleverly juggling high-sounding words including about OOP, etc. (I sometimes don't even understand more than half of the sayings)

And what's real?! Tinsel? Or not everyone has joined yet?
I must stress once again: if something complicated, ... unusual or requiring special knowledge - would have been written immediately, and here - the simplest (!). So turn on your brain and write options... Or wait!

 
Can you put it in a separate thread starting at https://www.mql5.com/ru/forum/1111/page2350#comment_9974834? It'll get lost in here, I want to see how the A100 is shitting liquid.
 
pavlick_:
I want to see how the A100 shits liquid.

Why are you making a fuss? Why don't you createa triple digitjob and let the tribunal decide who crapped themselves?

 
fxsaber:
Unfortunately, this option refers to


I haven't given the problem much thought. I did not find a solution on the spot, so I decided to learn it on the forum. The intrigues are not interesting, because I want to use in practice - Virtual-bibble, without which I can no longer imagine a combat EA.

I have already thought about it in different ways. If I understand correctly, it's the variability of type returned from the macro that matters. It may be solved in C++.

//------------------------------------ 1 вариант
template <typename T>
T f(T(*fp)()) {...}
//------------------------------------ 2 вариант
template <typename T>
struct Store {
   static inline T val;
};
int MACROS_helper_PrevHandle;
#define  MACROS(NEW_HANDLE_, FN_)   (MACROS_helper_PrevHandle=GetHandle())*0 == 0 ?           \
      (Store<decltype(FN_)>::val=SelectHandle(NEW_HANDLE_) ? FN_ : 0)*0 == 0 ?               \
      SelectHandle(MACROS_helper_PrevHandle)*0 == 0 ? Store<decltype(FN_)>::val : 0 : 0 : 0

But the gcc preprocessor can do it:

#define  M(FN_) ({int a=5; ; FN_;})
int ff() {return 50;}

int val = M(ff());

attempts to implement all this in µl ended in failure. Maybe the best solution is to modify SelectHandle(new, set_next=INT_MAX). Although, maybe someone will surprise me with a tricky macro.

Reason: