Einzelnen Beitrag anzeigen

Spectre

Registriert seit: 29. Jan 2013
Ort: Hamburg
65 Beiträge
 
Delphi XE2 Architect
 
#10

AW: 200+ Texte in ein memo laden

  Alt 17. Feb 2013, 15:11
gleiches problem :S

hier mal der ganze code. nur ein memo (memo1) und nen button auf der form..pfad ist auch korrekt und das land richtig in der txt benannt nach @@

Code:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    MyCountryDescriptions : TStringList;
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
    MyCountryDescriptions : TStringList;


implementation

{$R *.dfm}

Procedure CopyCountryDescription(Const Country : String; Description : TStrings);
Var
  i : Integer;
Begin

  Description.Clear;
  i:= MyCountryDescriptions.IndexOf('@@'+Country);
  if i=-1 then exit; // Keine Beschreibung gefunden
  inc(i);
  Description.BeginUpdate;
  Try
    while (i<MyCountryDescriptions.Count) do
      if Copy(MyCountryDescriptions[i],1,2) <> '@@' then
        break
      else begin
        Description.Add(MyCountryDescriptions[i]);
        inc(i);
      end
  finally
    Description.EndUpdate;
  end
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
MyCountryDescriptions := TStringList.Create;
MyCountryDescriptions.LoadFromFile('C:\MeinPfad\land.TXT');
CopyCountryDescription('Deutschland',Memo1.Lines);
FreeAndNil(MyCountryDescriptions);
end;

end.
Hab create, loadfromfile und freigabe dem button übergeben ist das ok?

Geändert von Spectre (17. Feb 2013 um 15:17 Uhr)
  Mit Zitat antworten Zitat