Hi friends,
I'm going to show the lasterror both on the terminal using the Print function and export it to the file.
First I used GetLastError() on the Print function and then again use it on the procedure of exporting it on the file when I found out that the GetLastError return zero on my file and as I read the documentation I found out the _LastError reset after first using of GetLastError().
Now I'm considering the use of _LastError instead of GetLastError() on both Print function and exporting the error code on the file. Is there any deficiency on using the _LastError compared to GetLastError() ?
I know there is another solution such as setting a variable equal to GetLastError() and then use that variable anywhere else I want, But my main issue is about the differences between _lastError and GetLastError().
Thanking in advance for your kind guidance,
- You already know the difference, GLE clears _LastError.
- Check your return codes for errors, and report them including GLE/LE. Don't look at it unless you have an error.
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi friends,
I'm going to show the lasterror both on the terminal using the Print function and export it to the file.
First I used GetLastError() on the Print function and then again use it on the procedure of exporting it on the file when I found out that the GetLastError return zero on my file and as I read the documentation I found out the _LastError reset after first using of GetLastError().
Now I'm considering the use of _LastError instead of GetLastError() on both Print function and exporting the error code on the file. Is there any deficiency on using the _LastError compared to GetLastError() ?
I know there is another solution such as setting a variable equal to GetLastError() and then use that variable anywhere else I want, But my main issue is about the differences between _lastError and GetLastError().
Thanking in advance for your kind guidance,