Autor Beitrag
Tobi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: So 21.12.03 13:16 
Die Datei woerter.wrd hat folgende Struktur:
[L1]
Wort1
Wort2
usw.
[L2]
Wort1
Wort2
usw.
[L3]
usw.

Nun soll es so sein, dass wenn der Anwender in einer Groupbox L1 auswählt automatisch der Inhalt von L1 (also alles was zw. L1 und L2 steht) in ein TStringList geladen wird.
Bisher hatte ich nur Fehlversuche, hat jemand ne Ahnung wie und ob es geht (es wird sicher gehen ;))?
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 21.12.03 13:28 
du müsstest nach einer zeile suchen, die mit [ anfängt. und dann weiter suchen bis zur nächsten [. die zeilen dazwischen sind doch dann die zeilen die du willst.

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Tobi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: So 21.12.03 13:39 
ja, so meinte ich das :)
aber wie gehts?
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 21.12.03 13:42 
So:
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:
procedure loadInto(var ziel : TStringList; const dateiname : Stringconst trenner : String);
VAR temp : TStringList;
    tempStr : String;
    anfang, ende : Integer;
begin
  temp := TStringList.Create;
  temp.LoadFromFile(dateiname);

  tempStr := temp.text;

  anfang:=Pos(trenner, tempStr);
  anfang := anfang + Length(trenner) +2//+2 wegen Zeilenumbruch
  ende := anfang;

  while (tempStr[ende] <> '['and (ende < Length(tempStr)) do inc(ende);

  temp.text := Copy(tempStr, anfang, ende - anfang);

  ziel.AddStrings(temp);

  temp.free;
end;


Diese Prozedur lädt die gewünschten Zeilen in eine StringList.

MfG
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".