GetLastError with Function name using if statement - page 3

 
anuj71 #:
Like this?


Yes, clearing the error code has the advantage you know where it is coming from, if you get one.
 
Dominik Egert #:
Almost. You are using the integer values 0 and 4000. You should be using the named constants.
I didn't understand?. Named Constants? Can you explain me or give me sample/example code. So, i can write my code based on it.
 
anuj71 #:
I didn't understand?. Named Constants? Can you explain me or give me sample/example code. So, i can write my code based on it.
Here:

if(_LastError != ERR_NO_ERROR && _LastError != ERR_NO_MQLERROR)
   Print(__FUNCTION__ + " => Buy Trailing Error Code : " + GetLastError());
 
Dominik Egert #:
Here:

Got it. Thanks for clarification.


Is there any advantage of using named Constants instead of Error Integer Value?

 
anuj71 #:

Got it. Thanks for clarification.


Is there any advantage of using named Constants instead of Error Integer Value?

Readability, and in case (very probable not to happen) the value actually changes, you don't have to fix your code. - So if MQ decides to assign new numbers to the errors, the named constants will update automatically. All you would require is a recompile, but not an editing.