Autor Beitrag
christian_m
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Di 22.05.07 13:34 
Hi @ all!!

Ich steh grad auf dem schlauch und komm nicht mehr weiter

Allgemein:

ausblenden Delphi-Quelltext
1:
2:
//Pseudocode
if (Bedingung1)= Wert1 or if (Bedingung2) ... Wert1 then ...


bei mir funktioniert das mit meinem Code jedoch nicht:

Zur Procedure: Figur1 soll auf ein ShapeX gehen, das die selbe Tagnummer hat
(Vorher wird noch eine Zahl gewürfelt und zur Tagnummer der Figur 1 addiert

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:
23:
procedure TForm1.Figur1DblClick(Sender: TObject);
var
  x: Integer;
begin
    for x := 1 to 20 do begin //20 Shapes  
// wenn Figur1 gleiche Nummer wie ShapeX hat, ...  
      if Figur1.tag = TShape(FindComponent('Shape'+inttostr(x))).tag)
       then begin  
{??? Überprüfe ob Figur2 oder Figur 3 schon auf ShapeX ist, auf das Figur 1 will}
       if (Figur2.tag  <> TShape(FindComponent('Shape'+inttostr(x))).tag  )
       or if (Figur3.tag  <> TShape(FindComponent('Shape'+inttostr(x))).tag  )
        then begin // dann wird die Figur1 auf das Feld bewegt
         Figur1.top := TShape(FindComponent('Shape'+inttostr(x))).top;
         Figur1.left := TShape(FindComponent('Shape'+inttostr(x))).left;
        break
       end
       else if Figur2.tag or Figur3.tag = TShape(FindComponent('Shape'+inttostr(x))).tag
       then ...

     
     end;
    end;
  end;


Die if-Anweisung funktioniert nur, wenn ich schreibe:
ausblenden Delphi-Quelltext
1:
if Figur2.tag  <> TShape(FindComponent('Shape'+inttostr(x))).tag  )					

wenn ich das gleichzeitig mit der Figur 3 machen will, geht das nicht; WIESO???


(kann man die "else if-Anweisung" auch so schreiben, dass abgefragt wird ob zwei Figuren die Nummer haben ??)

Danke im Vorraus
Chris

Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 22.05.07 13:39 
Syntax ist so:

ausblenden Delphi-Quelltext
1:
if (a=b) or (a=c) or (a=d) then DoSomething;					

_________________
We are, we were and will not be.