This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community
Bug with GlobalVariableSetOnCondition() ?Back to topics list |
|
emmanuel
2007.08.03 13:11
The definition of GlobalVariableSetOnCondition() says :
<< If there is no global variable, the function will generate error ERR_GLOBAL_VARIABLE_NOT_FOUND (4058) and return FALSE >> But if you execute : Print( "GlobalVariableSetOnCondition( \"GV_TEST\", 1.0, 2.0 ) returns ",GlobalVariableSetOnCondition( "GV_TEST", 1.0, 2.0 )," and GetLastError() is << ",ErrorDescription( GetLastError() )," >>" );
GlobalVariableSetOnCondition( "GV_TEST", 1.0, 2.0 ) returns 0 and GetLastError() is << no error >>
|
|
emmanuel
2007.08.03 20:27
I have some new ideas about this problem. It seems to come from GlobalVariablesDeleteAll().
If you call this function just before GlobalVariableSetOnCondition(), the problem occurs. This is the test (it's a SCRIPT, not an indicator) //+------------------------------------------------------------------+
//| TEST_SCRIPT.mq4
//|
//|
//| A test script to show a problem with the following commands :
//| - GlobalVariableSetOnCondition(...)
//|
//+------------------------------------------------------------------+
#include <stderror.mqh>
#include <stdlib.mqh>
int start()
{
// We delete all global variables to begin from scratch
GlobalVariablesDeleteAll();
/*
* The definition of GlobalVariableSetOnCondition() says ;
* << If there is no global variable, the function will generate
* error ERR_GLOBAL_VARIABLE_NOT_FOUND (4058) and return FALSE >>
*/
Print( "GlobalVariableSetOnCondition( \"GV_TEST\", 1.0, 2.0 ) returns ",
GlobalVariableSetOnCondition( "GV_TEST", 1.0, 2.0 ),
" and GetLastError() is << ",ErrorDescription( GetLastError() )," >>" );
return(0);
} |
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets
