Autor Beitrag
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: So 16.05.04 19:09 
...untyped pointer or untyped parameter.


Hallo, ich habe eine Funktion die überprüfen soll, ob in den Editfelder 1-6 die gleichen Buchstaben stehen.
Das mache ich mit if edit1.text <> edit2.text and if edit1.text <> edit2.text usw.

Allerdings bekomme ich wenn ich kompilieren will die oben beschriebene Fehlermeldung. Ich schreib mal meinen code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
if flatedit1.Text <> flatedit2.text and if flatedit1.text <> flatedit3.text and if flatedit1.Text <> flatedit5.text and if flatedit1.text <> flatedit4.text
 and if flatedit1.Text <> flatedit6.text and if flatedit2.text <> flatedit3.text and if flatedit2.text <> flatedit4.text and if flatedit2.text <> flatedit5.text
  and if flatedit2.text <> flatedit6.text and if flatedit3.text <> flatedit4.text and if flatedit3.text <> flatedit5.text and if flatedit3.text <> flatedit6.Text
   and if flatedit4.Text <> flatedit5.Text and if flatedit4.text <> flatedit6.text and if flatedit5.Text <> flatedit6.text then
      if flatedit1.text <> '' and if flatedit2.text <> '' and if flatedit3.text <> '' and if flatedit4.text <> '' and if flatedit5.text <> '' and if flatedit6.text <> '' then
         begin
           form3.memo1.lines.Clear;
           form3.Memo1.lines.Add(flatedit1.text);
           form3.Memo1.lines.Add(flatedit2.text);
           form3.Memo1.lines.Add(flatedit3.text);
           form3.Memo1.lines.Add(flatedit4.text);
           form3.Memo1.lines.Add(flatedit5.text);
           form3.Memo1.lines.Add(flatedit6.text);
           form3.Memo1.Lines.SaveToFile((Extractfilepath(paramstr(0) + 'Settings.ini')));
         end; {hier kommt der Fehler}


Der Fehler kommt in der letzten 'end' Zeile.

Ich hoffe mir kann jemand helfen.
Danke!
Benedikt
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 16.05.04 19:22 
Hi,

unabhängig davon, das es sicherlich saubere Methoden gibt, zu überprüfen ob in den Edits das gleiche drinsteht, liegt der syntaktische Fehler in deinem Code darin, das du nach jedem And wieder If schreibt, das ist jedoch zuviel.

ausblenden Delphi-Quelltext
1:
if ((Dieses) and (Jenes)) then					


und nicht

ausblenden Delphi-Quelltext
1:
if (Dieses) and if (Jenes) then					
Karlson Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: So 16.05.04 19:31 
Hi,

Danke schonmal für die antwort.
ich habe jetzt alle if's die zuviel waren entfernt, bekomme jetzt aber die Fehlermeldung Operator ist auf diesem Operandentyp nicht anwendbar...
Könntest du mir vielleicht eine wie du sagtest saubere Methode sagen? Die meine ist wirklich ziemlich unübersichtlich...


danke.
Martin77
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 282

XP Prof
D6 Prof, D7 Personal, D7 Enterprise, D8 personal
BeitragVerfasst: So 16.05.04 19:49 
Deine einzelnen Bedingungen müssen in Klammern geschrieben werden
ausblenden Delphi-Quelltext
1:
if (edit1.Text = edit2.text) and (edit2.text = edit3.text) then					


Martin
bms
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 735

Win XP
Delphi 3, Delphi 6 PE, Delphi 2005 PE
BeitragVerfasst: So 16.05.04 20:38 
Ist zwar nicht die saubeste Art, aber auf die Schnelle wäre auch ein :

ausblenden Delphi-Quelltext
1:
if flatedit1.Text <> flatedit2.text then if flatedit1.text <> flatedit3.text then if flatedit1.Text <> flatedit5 usw.					


Man müßte nur and gegen then tauschen. Funktionieren würde es.

Aber sauberer wäre das was man oben schon empfohnen hat.

ausblenden Delphi-Quelltext
1:
if (flatedit1.Text <> flatedit2.text) and (flatedit1.text <> flatedit3.text) and (flatedit1.Text <> flatedit5) usw.					

_________________
VORSICHT: Ich behersche seit heute die Fünf-Finger-Handflächen-Herz-Explodier-Schlag-Kampf-Technik >:(