Download MetaTrader 5

How does GetLastError() work ?

To add comments, please log in or register
ffoorr
1108
ffoorr  

Does the last error remain in the  GetLastError() fonction until a new error come

Or does the   GetLastError() fonction is reset ?

Keith Watford
Moderator
10614
Keith Watford  

Does the last error remain in the  GetLastError() fonction until a new error come

Yes 

Or does the   GetLastError() fonction is reset ?

No, unless you reset it with ResetLastError()

Usually , when calling a function, you can check the return value to see if there was an error or not. If there was an error call GetLastError() 

ffoorr
1108
ffoorr  
Thank's
honest_knave
Moderator
2318
honest_knave  

From GetLastError():

"After the function call, the contents of _LastError are reset."

whroeder1
16105
whroeder1  
honest_knave: From GetLastError():

"After the function call, the contents of _LastError are reset."

  1. And that used to be true before Build 600.
  2. Then the documentation said ResetLastError - MQL4 Documentation (29 Jul 2014)
    Note
    It should be noted that the GetLastError() function doesn't zero the _LastError variable. Usually the ResetLastError() function is called before calling a function, after which an error appearance is checked.
  3. And now it says
    Note
    The GetLastError() function  zero the _LastError variable.
To add comments, please log in or register