More to the point for you guys is the code that Thomas sent me today to tidy up the chart display. Those annoying gaps and places where text is overwritten are all gone. Brilliant.
You can add the code to any existing EA created from my shells since lifesys sent me the original code. Go to void Display(string text) and copy this over the top of the existing function:
Code: Select all
void Display(string text)
{
string lab_str = "OAM-" + IntegerToString(DisplayCount);
double ofset = 0;
string textpart[5];
uint w,h;
for (int cc = 0; cc < 5; cc++)
{
textpart[cc] = StringSubstr(text,cc*63,64);
if (StringLen(textpart[cc]) ==0) continue;
lab_str = lab_str + IntegerToString(cc);
ObjectCreate(lab_str, OBJ_LABEL, 0, 0, 0);
ObjectSet(lab_str, OBJPROP_CORNER, 0);
ObjectSet(lab_str, OBJPROP_XDISTANCE, DisplayX + ofset);
ObjectSet(lab_str, OBJPROP_YDISTANCE, DisplayY+DisplayCount*(fontSise+4));
ObjectSet(lab_str, OBJPROP_BACK, false);
ObjectSetText(lab_str, textpart[cc], fontSise, fontName, colour);
/////////////////////////////////////////////////
//Calculate label size
//Tomele supplied this code to eliminate the gaps in the text.
//Thanks Thomas.
TextSetFont(fontName,-fontSise*10,0,0);
TextGetSize(textpart[cc],w,h);
//Trim trailing space
if (StringSubstr(textpart[cc],63,1)==" ")
ofset+=(int)(w-fontSise*0.25);
else
ofset+=(int)(w-fontSise*0.65);
/////////////////////////////////////////////////
}//for (int cc = 0; cc < 5; cc++)
}
extern double spacingtweek = 0.6; // adjustment to reform lines for different font size
as it is no longer used. Ditto the function string FormatNumber(double x, int width, int precision).
You will find you can have text as large as you can reasonably want it without distorting the display.
Thanks Thomas. You have done as all a huge favour.