Hallo
traderdoc, meine Lösung sieht jetzt so aus:
Code:
int OnInit()
{
// == check user inputs before we continue
// == last: for real clock values
EventSetTimer(1); // 1 means every second
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
// == 1. kill real time clock
EventKillTimer();
// == 2. delete all created objects
for (int counter=-1;counter<19;counter++) ObjectDelete(indNames+(string)counter);
// == 3. print code why we were deinitialized
Print(__FUNCTION__," DeInit reason code = ",reason);
}
int OnCalculate (const int rates_total, // + more stuff
const int& spread[])
{
if (ShowInfo)
{
int C1end=70, C2end=10; // (C)olumn 1|2 end : right pixel end of column 1 and 2
int Hpls=0; // (H)orizontal (pl)u(s): used as Hpls*1 *2 for each new line
if (FontSize==10) Hpls=12;
else if(FontSize==9) Hpls=11;
else if(FontSize==8) Hpls=10;
if (ObjectFind(indNames+"0") ==-1)
{ // fixed objects in the first column
FuncCreateObject("1",C1end+HoriLeftShift,VerticalShift+Hpls*1,"local :",FontSize,FontName,normalColor,0);
}
} //== if (ShowInfo)
//== return the value of prev_calculated for next call
return(rates_total);
}
void OnTimer()
{
int C1end=70, C2end=10; // (C)olumn 1|2 end
int Hpls=0; // (H)orizontal (pl)u(s)
if (FontSize==10) Hpls=12;
else if(FontSize==9) Hpls=11;
else if(FontSize==8) Hpls=10;
datetime LocalTime=TimeLocal(); // = JJJJ.MM.DD hh:mm:ss
string TimeString=TimeToString(LocalTime,TIME_SECONDS ) ; // = hh:mm:ss
FuncCreateObject("11",C2end+HoriLeftShift,VerticalShift+Hpls*1, // name+positon
TimeString,FontSize,FontName,CounterColor // text+format
);
}
// FuncCreateObject is userdefined function
Ist das so schon ok oder kann man da noch was verbessern? Was mich ein bißchen stört ist die Wiederholung der Positionsbedingungen C1end,C2end,Hpls. Vielleicht sollten die besser in der FuncCreateObject() stehen.
Aber die Uhrzeit ist jetzt perfekt!
Danke noch mal für die Hilfestellung, war gar nicht so schwer. AVT