This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community
Strange 4008 error (ERR_NOT_INITIALIZED_STRING)Back to topics list |
|
emmanuel
2007.04.13 22:30
Declare an extern string, a local string and initialize them as empty strings :
extern string ExtParam2 = ""; string Param4 = ""; If you call a function with ExtParam2, a 4008 error (ERR_NOT_INITIALIZED_STRING) is generated. Why ??? ExtParam2 is initialized with an empty string ! The proof : if you call the same function with Param4, there is no error reported. I join a a small program to reproduce this behavior. I ever noted a problem with "string" input parameters (see "Problem when iCustom is called with an empty string") and I think these problems are linked.
//+------------------------------------------------------------------+
//| 4008.mq4 |
//| EMM |
//| |
//+------------------------------------------------------------------+
#property copyright "EMM"
#property link ""
#property indicator_chart_window
//---- input parameters
extern string ExtParam1;
extern string ExtParam2 = "";
extern string ExtParam3 = " ";
string Param4 = "";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
testCall( ExtParam1, "ExtParam1" );
testCall( ExtParam2, "ExtParam2" );
testCall( ExtParam3, "ExtParam3" );
testCall( Param4, "Param4" );
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
return(0);
}
void testCall( string paramValue, string paramName )
{
int lasterr = GetLastError();
if( lasterr > 4000 )
{
Print( "( testCall() - ERROR ) GetLastError : ",lasterr," for ",paramName," parameter !!);
}
}
|
|
Slawa
2007.04.19 10:20
Fixed. Please wait for next build.
|
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets
