When invoked, GetlastError() function resets last error code.
You can call it only once.
If you need error code multiple times, either create a variable and save the value of the GetLastError() or use _LastError variable and when you are finished displaying error code, you should call ResetlastError()
When invoked, GetlastError() function resets last error code.
You can call it only once.
If you need error code multiple times, either create a variable and save the value of the GetLastError() or use _LastError variable and when you are finished displaying error code, you should call ResetlastError()
Perfect, I've applied the following:
if(!ObjectCreate(0,"spread_indicator",OBJ_LABEL,0,0,0 )){ SendMail("Error Code #"+IntegerToString(_LastError)+" has occured","The Error Code #"+IntegerToString(_LastError)+" has unfortunately occured on ticket number #"+IntegerToString(OrderTicket(),0)+".\n\nFor a complete list of MQL4 Error Codes, visit https://docs.mql4.com/constants/errorswarnings/errorcodes"); PrintFormat("Error Code for Spread Indicator #%d ", _LastError); MessageBox("There was an error with the Spread Indicator function. Please report #"+IntegerToString(_LastError),"Object Create Error",MB_OK | MB_ICONERROR); ResetLastError(); }
All seems to be working now.
Much appreciated.
SendMail("Error Code #"+IntegerToString(_LastError)+" has occured","The Error Code #"+IntegerToString(_LastError)+" has unfortunately occured on ticket number #"+IntegerToString(OrderTicket(),0)+".\n\nFor a complete list of MQL4 Error Codes, visit https://docs.mql4.com/constants/errorswarnings/errorcodes"); PrintFormat("Error Code for Spread Indicator #%d ", _LastError);
Now you are printing the error code for SendMail.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Morning all,
Why am I having formatting issues with my debug printing?
Despite reading the following documentation: https://docs.mql4.com/common/printformat and despite having the following code:
the Journal is returning:
Despite my MessageBox() function returning an actual error code (4200 - I know why the error is returning, I'm testing the diagnostics of the EA), by applying the following:
Many thanks,