Download MetaTrader 5

CChartObjectLabel Description problem

To add comments, please log in or register
Sell products right in MetaTrader. Millions of traders are waiting for this!
chinaski
890
chinaski 2012.10.11 00:33 

Hello,

there is a problem with  CChartObjectLabel::Description function.

Please look at the sample below. It should print 0 to console as Description is empty. 

 

 CChartObjectLabel     x_label;
 x_label.Create(0,"name",0,100,100);
 x_label.Description("");
                
 string x=x_label.Description();
 Print("StringLen=",IntegerToString(StringLen(x)));

Unfortunately, it returns 1. What is the reason ?

thank you 

Andrey Voytenko
23090
Andrey Voytenko 2012.10.11 09:00  
//+------------------------------------------------------------------+
//| Set comment of object. |
//+------------------------------------------------------------------+
bool CChartObject::Description(const string new_text) const
{
//--- checking
if(m_chart_id==-1) return(false);
//--- tuning
if(new_text=="") return(ObjectSetString(m_chart_id,m_name,OBJPROP_TEXT," ")); <<--- if text="" then set text=" "
//--- result
return(ObjectSetString(m_chart_id,m_name,OBJPROP_TEXT,new_text));
}

chinaski
890
chinaski 2012.10.11 14:56  
avoitenko:

Hello avoitenko,

thank you. This explains it. Don't know how to access source code.

By the way: const string new_text makes no sense as new_text is a local copy.

const string& new_text would be better 

Andrey Voytenko
23090
Andrey Voytenko 2012.10.11 15:55  
Don't know how to access source code.

Right click and select Go To Definition.


chinaski
890
chinaski 2012.10.11 18:04  

oh well, thank you.


To add comments, please log in or register