if(FileReadStruct(handle,temp_rate)!=60)
{
IsError=true;
Print(__FUNCSIG__," Не удалось прочитать данные из файла по причине ошибки ",GetLastError());
return;
}
However, some functions are void type and others return a value, so I return zero from them:
return(0);
Can I make a magic macro that substitutes the right one for me in each case?
However, some functions are void type and others return a value, so I return zero from them:
Can I make such a magic macro, which in each case would substitute for me the necessary variant?
Using return in a macro is a cocked gun pointed at its own leg, and when combined with if - it turns into a cannon))) But if you really want to:
#define CHECK_READ(dHndl,dRate,dRet) do \
if(FileReadStruct(dHndl,dRate)!=60){ \
IsError=true; \
Print(__FUNCSIG__," Не удалось прочитать данные из файла по причине ошибки ",GetLastError()); \
return dRet;} while(false)
...
CHECK_READ(handle,temp_rate,);
...
CHECK_READ(handle,temp_rate,0);
...
I haven't tested it, but it should work. Also turned the gun back into a pistol)))
So I pass in the last parameter either a value for return, or a blank, which will turn into
return ;
and a space means nothing. Of course, how did I forget that it can be used without my favourite brackets.
return(x);
return x; //равноценны
By the way, could you tell why this construct is inside a loop, which can be executed only once? Is it a gun, turned back into a gun? Are there possible situations like infinite recursion or something like that?
So I pass in the last parameter either a value for return, or a blank, which will turn into
and a space means nothing. Of course, how did I forget that it can also be used without my favourite brackets.
By the same token, can you tell me why this construct is stuffed inside a loop that can only be executed once? Is it a gun turned back into a gun? Possible situations like infinite recursion or something like that?
if (condition) CHECK_READ(h,r,0); else CHECK_READ(h,r,1);
Deploy the macro without the do-while wrapper and see what happens)))
Vladimir Simakov: if (condition) CHECK_READ(h,r,0); else CHECK_READ(h,r,1);
Deploy the macro without the do-while wrapper and see what happens))
if (condition) if(FileReadStruct(h,r)!=60){
IsError=true;
Print(__FUNCSIG__," Не удалось прочитать данные из файла по причине ошибки ",GetLastError());
return 0;}; else if(FileReadStruct(dHndl,dRate)!=60){
IsError=true;
Print(__FUNCSIG__," Не удалось прочитать данные из файла по причине ошибки ",GetLastError());
return dRet;};
=
if (condition)
if(FileReadStruct(h,r)!=60)
{
IsError=true;
Print(__FUNCSIG__," Не удалось прочитать данные из файла по причине ошибки ",GetLastError());
return 0;
};
else
if(FileReadStruct(dHndl,dRate)!=60)
{
IsError=true;
Print(__FUNCSIG__," Не удалось прочитать данные из файла по причине ошибки ",GetLastError());
return dRet;
};
That seems to be the case, if I understand the substitution principle correctly.
Extra semicolons after curly brackets. And it's not clear what else refers to now.
It's a pity there's apparently no easy way to automate macro expansion to see what happens. Unless you can make your own script.
Thank you! There is a reason there is no semicolon after while in the macro.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Do you want it for mt4 or mt5? I deleted the code I posted. I did not immediately notice that mt4 was discussed here
MQL4
MQL4
I advise you - there are a lot of good things to findhttps://www.mql5.com/ru/forum/131859/page6#comment_3359705
A more specific and perhaps interesting question:
I use the same construct in different functions
However, some functions are void type and others return a value, so I return zero from them:
Can I make a magic macro that substitutes the right one for me in each case?
A more specific and perhaps interesting question:
I use the same construct in different functions
However, some functions are void type and others return a value, so I return zero from them:
Can I make such a magic macro, which in each case would substitute for me the necessary variant?
Using return in a macro is a cocked gun pointed at its own leg, and when combined with if - it turns into a cannon))) But if you really want to:
I haven't tested it, but it should work. Also turned the gun back into a pistol)))
Thank you!
So I pass in the last parameter either a value for return, or a blank, which will turn into
return ;and a space means nothing. Of course, how did I forget that it can be used without my favourite brackets.
By the way, could you tell why this construct is inside a loop, which can be executed only once? Is it a gun, turned back into a gun? Are there possible situations like infinite recursion or something like that?
Thank you!
So I pass in the last parameter either a value for return, or a blank, which will turn into
and a space means nothing. Of course, how did I forget that it can also be used without my favourite brackets.
By the same token, can you tell me why this construct is stuffed inside a loop that can only be executed once? Is it a gun turned back into a gun? Possible situations like infinite recursion or something like that?
if (condition) CHECK_READ(h,r,0); else CHECK_READ(h,r,1);
=
That seems to be the case, if I understand the substitution principle correctly.
Extra semicolons after curly brackets. And it's not clear what else refers to now.
It's a pity there's apparently no easy way to automate macro expansion to see what happens. Unless you can make your own script.
Thank you! There is a reason there is no semicolon after while in the macro.