Hi!
Das Programm stellt Inhalt einer Datei dar. Die Datei wird laufend geschrieben und gleichzeitig wird gelesen (formatiert) und dargestellt. Es wird mittels C++Builder6 (Borland) geschrieben.
//*************************
Logfile - Inhalt : so schaut meine Logdatei, wenn das Programm am Ende ist
//***************************.
…
Dies ist mein Timer - formatiert und stellt die Ausgabe dar.
void __fastcall TForm1::TimerTimer(TObject *Sender){
AnsiString sXFText;
AnsiString sCurrent;
AnsiString sXTText;
TStringList* outStrings; //declared global and the with new
//initialized and somewhere deallocated
int tikers = 0;
outPut();//output data - here writing into the file is done
//###################################
//outStrings liefert immer korrektes Ergebnis (Aktueller Inhalt der
// Log-Datei)
while (tikers Count){//goes through the file line
//after another
AnsiString line = outStrings->Strings[tikers++].Trim();
if (line.Empty())
break;
AnsiString token = line.SubString(0,2); //gets the 1st.2
//chars like XF,XT, XA
if (tikersElements.Pos(token) != 0){//finds out which
//tickerelement and prepare for display
if (token == „XF“) {
sXFText = line;
sCurrent = sXFText;
}
else if (token == „XT“){
sXTText = line;
sCurrent = (sXFText + " | " + sXTText);
}
else if(token == „XA“){
sCurrent =(sXFText + " | " + sXTText + " | " + line);
break;
}
}
Ticker->Text = sCurrent; //so that it would not clear before
//the next is written by the writer
//with this the data is displayed
}//end of while (…)
}//end of TimerTimer
//**************************
Hier ist die Sequenz für die Ausgabe/Darstellung
//***************************
XF: hp, Zustand: Laufend //first sequence being displayed
XF: hp, Zustand: Laufend | XT: XTF_OpenURL, Zustand: GUT //second
//sequence displayed
XF: hp, Zustand: Laufend | XT: Google, Zustand: GUT //third
//seq.displayed
XF: hp, Zustand: Laufend | XT: GoogleHp, Zustand: GUT //4th. seq.
//displayed
XF: hp, Zustand: GUT //the last sequence - displayed
…
When ich die Anzahl von XT`s aufzähle, es liefert 6 anstatt 3.
Irgend was is läuft schief mit dem Timer-Code (siehe oben), aber
ich kann nicht genau sagen, was und warum.
Ich habe eine Funktion geschrieben, um zu sehen wie die Ausgabe ausschaut.
void Memo(TStringList *MyList){
std::auto_ptrSummaryList(new TStringList);
static int i;
if (g_bFirst){//g_bFirst is bool, that gives true or false
for(i = 0; i Count; i++){
if (AnsiPos(„XF:“, MyList->Strings[i])){
SummaryList->Add(MyList->Strings[i]);
}
else{
if (AnsiPos(„XT:“, MyList->Strings[i])){
SummaryList->Add((" " + MyList->Strings[i]));
}
else{if(AnsiPos(„XA:“,MyList->Strings[i])){
SummaryList->Add((" " +MyList->Strings[i]));
}
}
}//end of for (i = 0;…
}//end of if(g_bFirst)
}
//****************************
Summary of the sequence-output - Die Ausgabe des obigen Code
//***************************
XF: hp, Zustand: Laufend
XF: hp, Zustand: Laufend
XT: XTF_OpenURL, Zustand: GUT
XF: hp, Zustand: Laufend
XT: XTF_OpenURL, Zustand: GUT
XT: Google, Zustand: GUT
XF: hp, Zustand: Laufend
XT: XTF_OpenURL, Zustand: GUT
XT: Google, Zustand: GUT
XT: GoogleHp, Zustand: GUT
XF: hp, Zustand: GUT
…
Summary of the sequence-output is supposed to be - So soll die Ausgabe
ausschauen.
XF: hp, Zustand: Laufend
XT: XTF_OpenURL, Zustand: GUT
XT: Google, Zustand: GUT
XT: GoogleHp, Zustand: GUT
XF: hp, Zustand: GUT
Wenn die Log-Datei besteht, d.h. when der Writer fertig ist und when
ich mein Program wieder starte ohne Writer, das Ergebnis is korrekt, wie
es sein soll, auch Anzahl von XTs ist 3. Ich habe auch den Inhalt der Log-Datei
in einem Vektor kopiert und von Vektor verwaltet (in TimerTimer), das hat nichts
geholfen. Ich würde mich auf jede Hilfe/Tipps freuen.
Danke im Voraus!
Harp