Autor Beitrag
bruce185
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Sa 08.09.07 00:12 
Hallo,
ich habe eine Textdatei die mehr als 5000 Zeilen enthält und diese tuh ich mit der For schleife in Memo1 hinzufügen über StringListe, die werden einzelnd hinzugefügt aber mein Programm hängt sich solange auf, bis die Zeile erreicht wurde.
Gibt es ein befehl um dies zu verhindern, also das die Schleife läuft ohne das es hängt?

Vielen Dank schonmal.

MfG
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 08.09.07 00:17 
Kannst Du den Source zu deinem Problem bitte mal kurz mit posten? Ich glaub, Du hast nicht nur mit dem Hängen ein Problem, sondern allgemein was vergessen.

Grob: Wenn man in ein Memo große Datenmengen einfügt, sollte man dies der VCL vorher mitteilen.
Zweitens: Wenn Du die Datei laden willst und dabei den Inhalt des Memos löschen willst, kannst Du auch direkt in das Memo laden lassen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 08.09.07 00:17 
Suche in: Delphi-Forum, Delphi-Library APPLICATION.PROCESSMESSAGES aber warum nicht gleich mit Memo1.Lines.LoadFromFile(Datei); ?

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Sa 08.09.07 00:47 
Danke euch.
Ich möchte es erst in TStringList speichern und auf Button1 Klick das ganze in Memo laden, ich weiss, ich hätte das auch so machen können, aber naja, vieleicht werde ich das dann so machen.

Ich werde das mal probieren ob das was hilft.

Vielen Dank.

MfG
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 08.09.07 00:52 
An sonsten die Stringlist so deklarieren:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var s: TStrings;
begin
   s:=TStringList.Create;
   //Datei laden
   Memo1.Lines.Assign(s); //in memo übertragen

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 08.09.07 01:01 
Nicht vergessen Memo1.Lines.BeginUpdate und Memo1.Lines.EndUpdate in einem Try-Finally-Block um die Zuweisung (das Übertragen der Daten in's Memo) zu nutzen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Sa 08.09.07 01:30 
Danke euch.
Also, ich muss die Textdatei zeile für zeile ins Memo schreiben weil ich bei jeder zeile etwas mit anhängen möchte.

bsp:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i:=0 to Liste.Count-1 do begin
  Application.ProcessMessages;
  Memo1.Lines.Add(IntToStr(i+1)+'. '+Liste.Strings[i]);
end;


deshalb kann ich nicht LoadFromFile benutzen. :wink:

EDIT: Application.ProcessMessages kam mir bekannt vor da ich früher viel in C++ Programmiert habe also den C++ Builder von Borland, nur habe ich teilweise an befehlen vergessen.
Also es funktioniert jetzt, vielen dank für die hilfen.

MfG
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 08.09.07 02:14 
Schreib mal statt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i:=0 to Liste.Count-1 do begin
  Application.ProcessMessages;
  Memo1.Lines.Add(IntToStr(i+1)+'. '+Liste.Strings[i]);
end;

das hier:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Memo1.Lines.BeginUpdate;
try
    for i:=0 to Liste.Count-1 do begin
        If i and $3FF = 0 Then
            Application.ProcessMessages;
        Memo1.Lines.Add(IntToStr(i+1)+'. '+Liste.Strings[i]);
    end;
finally
    Memo1.Lines.EndUpdate;
end;

und du wirst nicht mal merken, dass Du Zeilen hinzufügst, da die nahezu sofort da sind ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Sa 08.09.07 02:27 
Sry, das habe ich vergessen, du meintest ja wegen fehlermeldung abzufangen.
Ich werd das dann so machen, vielen dank.

try... except ist für fehlermeldung abzufangen, ich weiss leider nicht, was dein Code bewirkt, es funktioniert ja auch so ohne fehlermeldung.

EDIT: Achso, ok vielen dank, dann werde ich es wohl so machen.

MfG