Autor Beitrag
Handycommander
ontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1054

Windows XP Pro, Vista
Visual Studio 2008
BeitragVerfasst: Mo 01.08.05 15:43 
hi,

ich habe einen stream so gespeichert:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.StreamSave;
var
  Stream: TFileStream;
begin
  Stream := TFileStream.Create(ComboBox1.Text + 'File.txt', fmCreate);
  Stream.Write(PChar(Label10.Caption + #13#10 + Label8.Caption + #13#10 + Label9.Caption)^, Length(Label10.Caption + #13#10 + Label9.Caption + #13#10 + Label8.Caption));
  Stream.Free;
end;


das klappt auch wunderbar, dass der immer eine neue zeile anfängt (insg. 3 zeilen).
so nun möchte ich diese 3 zeilen wieder in 3 Labels teilen.
also jede zeile in ein label.
habs schon versucht, komme aber nicht weiter, weil er des ned ausließt.
weiß jemand rat?

danke
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Mo 01.08.05 15:52 
Was heisst nicht ausliesst? Kriegst du keine Daten vom File in den Stream oder ist das Problem woanders?

_________________
Bravery calls my name in the sound of the wind in the night...
Handycommander Threadstarter
ontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1054

Windows XP Pro, Vista
Visual Studio 2008
BeitragVerfasst: Mo 01.08.05 16:04 
ich weiß nicht, wie ich den stream von dem file auslese und dann in 3 labels teile
also 1. zeile in label1
und so weiter...
Grendel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 443

Gentoo Linux, MacOS X, Win 2000
D5 Ent, D7 Ent, Lazarus, Anjuta, MonoDevelop
BeitragVerfasst: Mo 01.08.05 16:18 
user profile iconHandycommander hat folgendes geschrieben:
ich weiß nicht, wie ich den stream von dem file auslese

per Filestream folgendermaßen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
  fs  : TFileStream;
  sBuf: String;
begin
  fs := TFileStream.Create('file.txt', fmOpenRead);
  SetLength(sBuf, fs.Size);
  fs.Read(PChar(sBuf)^, fs.Size);
  fs.Free();
end;



user profile iconHandycommander hat folgendes geschrieben:
und dann in 3 labels teile
also 1. zeile in label1
und so weiter...

In diesem Fall nimmst Du besser eine TStringList und lädst die Datei per LoadFromFile(). Die einzelnen Zeilen kannst Du dann per StringList.Strings[zeilennummer] ansprechen.

Beim einlesen per FileStream kannst Du ebenfalls eine TStringList nehmen und den eingelesenen String an StruingList.Text zuweisen. Auch dann kannst Du über StringList.Strings[[zeilennummer] die einzelnen Zeilen ansprechen.

Bis neulich ...
Handycommander Threadstarter
ontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1054

Windows XP Pro, Vista
Visual Studio 2008
BeitragVerfasst: Mo 01.08.05 16:46 
ok danke
hat geklappt
Sandy81
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Fr 25.08.06 18:31 
Titel: Inhalt einer Stream Datei in Delphi anzeigen
suche schon seit tagen in sämtl. foren, wie man streams auslesen kann. mein problem wird hier schön dargestellt, allerdings fehlt mir das nötige hintergrundwissen. wie schaut ein solcher quelltext aus (bezogen auf tstringlist und loadfromfile())? wäre super schön von euch, wenn ihr mir da helfen könntet, da ich erst seit 2 wochen mit delphi "versuche" zu programmieren.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 25.08.06 18:38 
In diesem Fall wäre die Methode LoadFromStream die richtige.

_________________
Markus Kinzler.
Sandy81
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Fr 25.08.06 19:30 
Titel: danke
vielen dank für die schnelle antwort. bin aber schon fündig geworden unter:

www.delphi-forum.de/...mp;highlight=streams