Search code examples
openclmql5metatrader5

How to get an error message instead of an integer in MQL5?


I am trying to get the error message using OpenCl in MQL5.

int     cl_ctx;
if (  ( cl_ctx = CLContextCreate( CL_USE_ANY ) ) == INVALID_HANDLE )
{
      Print( "OpenCL not found: ", GetLastError() );

      float pr  = 2.0 / ( period + 1.0 );
      result[0] = (float)price[position] * pr + prev_value * ( 1 - pr );

      Print(  result[0] );
      return( result[0] );
}

I am getting the message as:

OpenCL not found: 5113

Now I do not know what this 5113 means. How I can get the message in human readable format that will help me debug my program effectively?


Solution

  • In case your code received _LastError == 5113:

    the documented human-readable explanation is this one:

    ERR_OPENCL_TOO_MANY_OBJECTS 5113 Too many OpenCL objects

    Next time, better present a few "surrounding" lines via a copy/paste from the MT5-log, there are more details surrounding the Runtime Error incident.

    All error-code definitions and explanations are kept both in documentation and in < stderror.mqh > file since ever.

    Also may re-read the online documentation aids.

    Lastl, but not least, always pre-clear _LastError state with a call to ResetLastError()