Autor Beitrag
arminho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 07.03.05 15:47 
hallo leute,
ich habe ein problem...
ich will die erste zeile meiner textdatei in ein label unterbringen.
habs mal so versucht, funktioniert aber nicht...dass label bleibt leer. wo liegt der fehler?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.Image1Click(Sender: TObject);
var
G: textfile;
s: string;
begin
assignfile(G,ExtractFilePath(Application.ExeName)+'clubdateien\clubdatei.clb');
  try
    reset(G);
    while not eof(G) do
begin
        readln(G,s);
        label21.caption:=(s);

        end;
  finally
    closefile(G);
end;
end;
wdbee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 628
Erhaltene Danke: 1



BeitragVerfasst: Mo 07.03.05 15:52 
Was sollen denn die Klammern um s?

ausblenden Delphi-Quelltext
1:
Label.Caption := s;					
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 07.03.05 15:57 
Da du die ganze Datei einliest (while not eof), könnte es sein, das die letzte Zeile leer ist?
arminho Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 07.03.05 16:38 
ja, er liest die letzte Zeile der Datei...er soll aber die erste lesen...hä?
arminho Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 07.03.05 16:39 
ja ok ich habs jetzt wegen dem eof....ist ja klar
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 07.03.05 16:40 
Habe dir doch den wichtigen Hinweis gegeben:
While ist eine Schleife!
Du musst if benutzen.
arminho Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 07.03.05 16:53 
jetzt will er mir aber eine zeile nicht ins memo1 einfügen...fehler: Inkompatible Typen: 'TStrings' und 'String'

sieht jetzt so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
procedure TForm1.Image1Click(Sender: TObject);
var
G: textfile;
s: string;
begin
opendialog1.filename:='*.clb';
opendialog1.filter  :='Clubdaten|*.clb';
if opendialog1.execute then
begin
assignfile(G,opendialog1.filename);
  try
    reset(G);
begin
        readln(G,s);
        label21.caption:=s;
        readln(G,s);
        readln(G,s);
        readln(G,s);
        readln(G,s);
        form3.memo1.Lines:=s; // Hier ist der Fehler !!!
        

        end;
  finally
    closefile(G);
end;
end;
end;
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 07.03.05 16:55 
Die Fehlermeldung stimmt. 8)
ausblenden Delphi-Quelltext
1:
form3.memo1.Lines.Add(s);					
arminho Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 07.03.05 16:57 
vielen dank, was so ein kleines wort "add" doch ausmacht... :oops: