Is there an EOL marker or crlf pair?

 

I'm trying to draw a multilined label


ObjectCreate("Myobject", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Myobject", "This is some text on line one " + CRLF + "This is the text on line two", 10, "Times New Roman", Yellow);


How do I implement the CRLF (or EOL)?


-Jerry

 
Try this:
string str;
str=StringConcatenate ("This is some text on line one ",CRLF,"This is the text on line two");

ObjectCreate("Myobject", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Myobject", str, 10, "Times New Roman", Yellow);

 

Thanks Roger


It's the CRLF bit that I am stuck on. How do you represend a CRLF in MQL4 speak? In VB you could have chr$(10), chr$(13).


-Jerry

 
Sorry, I thought it's your variable. So, your construction is good:
ObjectCreate("Myobject", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Myobject", "This is some text on line one \nThis is the text on line two", 10, "Times New Roman", Yellow);
 
Roger:
Sorry, I thought it's your variable. So, your construction is good:

That doesn't work either. I get a square box where a new line should be.


-Jerry

 
So, it means you have to create two objects.
 
netconuk wrote >>

ObjectCreate("Myobject", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Myobject", "This is some text on line one " + CRLF + "This is the text on line two", 10, "Times New Roman", Yellow);

How do I implement the CRLF (or EOL)?

Jerry,

You need to use ObjectSet() and programmatically set the OBJPROP_XDISTANCE and OBJPROP_YDISTANCE values in order to achieve the appearance of a new line. Just to give you an example, the following code segment will produce Legends in matching colours with the index lines.

//+------------------------------------------------------------------+
//| Creates legends for a set of colour index lines.
//|
//| REQUIREMENTS
//| The correlated symbol/pair will appear separately as a text object
//| in the same colour as the index.
//+------------------------------------------------------------------+
void CreateLegends()
{
   g_colours[0] = Red;
   g_colours[1] = Blue;
   g_colours[2] = Yellow;
   g_colours[3] = White;
   g_colours[4] = Plum;
   g_colours[5] = Lime;
   g_colours[6] = Silver;
   g_colours[7] = Aqua;

   g_short_name = "CORREL(" + CORRELPeriod + ")";
   IndicatorShortName(g_short_name);
   int win_idx = WindowFind(g_short_name);
   int limit = ArraySize(g_correlated_pairs);
   for (int i = 0; i < limit; i++)
   {
      if (ObjectFind(g_short_name + g_correlated_pairs[i]) == -1)
      {
         ObjectCreate(g_short_name + g_correlated_pairs[i], OBJ_LABEL, win_idx, 0, 0);
         ObjectSet(g_short_name + g_correlated_pairs[i], OBJPROP_XDISTANCE, 10);
         ObjectSet(g_short_name + g_correlated_pairs[i], OBJPROP_YDISTANCE, 10+i*14);
         ObjectSet(g_short_name + g_correlated_pairs[i], OBJPROP_CORNER, 1);
         ObjectSetText(g_short_name + g_correlated_pairs[i], g_correlated_pairs[i], DEFAULT_FONT_SIZE, DEFAULT_FONT_NAME, g_colours[i]);
      }
   }
}

Reason: