Files
mql5-skills/skills/mql5/references/docs/04-common/0240-common-setusererror.md
T
2026-06-23 21:47:51 +08:00

42 lines
961 B
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# SetUserError
Sets the predefined variable [_LastError](/en/docs/predefined/_lasterror) into the value equal to [ERR_USER_ERROR_FIRST](/en/docs/constants/errorswarnings/errorcodes#err_user_error_first) + user_error
```
void  SetUserError(
   ushort user_error,   // error number
   );
```
Parameters
user_error
[in] [Error](/en/docs/constants/errorswarnings/errorcodes) number set by a user.
Return Value
No return value.
Note
After an error has been set using the SetUserError(user_error) function, [GetLastError()](/en/docs/check/getlasterror) returns value equal to [ERR_USER_ERROR_FIRST](/en/docs/constants/errorswarnings/errorcodes#err_user_error_first) + user_error.
Example:
```
void OnStart()
  {
//--- set error number 65537=(ERR_USER_ERROR_FIRST +1)
   SetUserError(1);
//--- get last error code
   Print("GetLastError = ",GetLastError());
/* 
   Result
   GetLastError = 65537
*/ 
  }
```