Autor Beitrag
Bastian25
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38

Win XP
D7 Pers
BeitragVerfasst: Mi 19.01.05 16:54 
Ich habe ein Programm geschrieben, daß einen text zerlegen soll!
Dazu habe ich ganz am Anfang mit OpenDialog gearbeitet, leider funktioniert es nicht und erhalte folgende Fehlermeldung:
''Feld Form1.OpenDialog enthält keine entsprechnede Komponente!''
Kann mir jemand helfen?

Hier der Quelltext:

ausblenden volle Höhe 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:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    OpenDialog1: TOpenDialog;
    Button1: TButton;
    Button2: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    RadioGroup1: TRadioGroup;
    Button3: TButton;
    constructor Create(aOwner: TComponent); override;
    destructor Destroy(); override;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);

  private
    { Private-Deklarationen }
    Zeilen: TStrings;
    LaufendeZeile: Integer;

  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

constructor TForm1.Create(aOwner: TComponent);
begin
  inherited Create (aOwner);   //ruft Constructor der Basisklasse auf
  Laufendezeile := 0;
  Zeilen := TStringList.Create;     //TStringList verwaltet eine Liste, die Strings enthält.

  RadioGroup1.Enabled := false;
  Button2.Enabled := false;

end;

destructor TForm1.Destroy;        // gibt Objekt im Speicher frei
begin
  inherited Destroy;
  Zeilen.Destroy;
end;



procedure TForm1.Button1Click(Sender: TObject);
var
  t: TextFile;
  s: String;
begin
  if OpenDialog1.Execute then
    begin
    LaufendeZeile := 0;
    Zeilen.Clear;

    AssignFile(t, OpenDialog1.Filename);
    Reset(t);

      repeat
        ReadLn(t,s);
        Zeilen.Add(s);
      until EoF(t);

      RadioGroup1.Enabled := true;
      Button2.Enabled := true;
    end;
end;


procedure TForm1.Button2Click(Sender: TObject);
var
s,
t1,
t2,
t3,
t4: String;
ch:Char;
i,
z1,
z2 : Integer;
begin
  RadioGroup1.Enabled := false;
  Edit1.Text :='';
  Edit2.Text :='';
  Edit3.Text :='';
  Edit4.Text :='';
  Edit5.Text :='';
  Edit6.Text :='';

  if LaufendeZeile < Zeilen.Count then
  begin
  s := Zeilen[LaufendeZeile];

    case RadioGroup1.ItemIndex of
    0: ch :='#';
    1: ch :=',';
    2: ch :=';';
    3: ch :='.';
    4: ch :='%';
    5: ch :='&';
    else
    ch := ' ';
  end;

  i := Pos(ch,s);

  if i <> 0 then
  begin

    z1 := StrToInt(copy(s,1,i-1));
    Delete(s,1,i);
    Edit1.Text := IntToStr(z1);

    i :=Pos(ch,s);
    z2 := StrToInt(copy(s,1,i-1));
    Delete(s,1,i);
    Edit2.Text := IntToStr(z2);

    i :=Pos(ch,s);
    t1 :=copy(s,1,i-1);
    Delete(s,1,i);
    Edit3.Text := t1;

    i :=Pos(ch,s);
    t2 :=copy(s,1,i-1);
    Delete(s,1,i);
    Edit4.Text := t2;

    i :=Pos(ch,s);
    t3 :=copy(s,1,i-1);
    Delete(s,1,i);
    Edit5.Text := t2;

    t4:= s;
    Edit6.Text := t4;
    end
    else
      Edit1.Text := s;

      LaufendeZeile := LaufendeZeile +1

  end;

  if LaufendeZeile >= Zeilen.Count then
  Button2.Enabled := false;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
close
end;

end.



Gruß Bastian
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Mi 19.01.05 17:10 
Heisst der jetzt OpenDialog oder OpenDialog1?
Bastian25 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38

Win XP
D7 Pers
BeitragVerfasst: Mi 19.01.05 17:12 
Opendialog1
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Mi 19.01.05 17:14 
Probier mal im Object Inspector (oder wie der auf D heisst) OpenDialog1 in OpenDialog umzubenennen. Irgendwie scheint die DFM nicht mehr zur PAS zu passen.
Bastian25 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38

Win XP
D7 Pers
BeitragVerfasst: Mi 19.01.05 17:26 
Jupp, jetzt passt es!
Hatte wohl nen Brett vorm Kopf! :shock:
Danke!