Download MetaTrader 5

CChartObjectLabel Description problem

To add comments, please log in or register
chinaski
898
chinaski  

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
23544
Andrey Voytenko  
//+------------------------------------------------------------------+
//| 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
898
chinaski  
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
23544
Andrey Voytenko  
Don't know how to access source code.

Right click and select Go To Definition.


chinaski
898
chinaski  

oh well, thank you.


To add comments, please log in or register