Autor Beitrag
van RanDahlE
Hält's aus hier
Beiträge: 15



BeitragVerfasst: So 02.12.07 12:09 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
z:=4;
case Random(z) of
 0:(xxx.left:=96and (xxx.Top:=64);        
 1:(xxx.left:=192and (xxx.Top:=64);       
 2:(xxx.left:=296and (xxx.Top:=64);       
 3:(xxx.left:=400and (xxx.Top:=64);      
 4:(xxx.left:=96and (xxx.Top:=152);       
                   .
                   .
                   .  
end;

der sagt mir : Operator not applicable to this operand type

...im Grunde soll der nur durch Zufall ein Imageobjekt verschieben..kann mir wer sagen was ich da falsch mache oder mir ne Alternative aufzeigen?

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: So 02.12.07 12:10 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
0:
  begin
    //bla
    //blub
  end;

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
Fabian E.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 554

Windows 7 Ultimate
Visual Studio 2008 Pro, Visual Studion 2010 Ultimate
BeitragVerfasst: So 02.12.07 12:25 
user profile iconvan RanDahlE hat folgendes geschrieben:
z:=4;
case Random(z) of
0:(xxx.left:=96) and (xxx.Top:=64);
1:(xxx.left:=192) and (xxx.Top:=64);
2:(xxx.left:=296) and (xxx.Top:=64);
3:(xxx.left:=400) and (xxx.Top:=64);
4:(xxx.left:=96) and (xxx.Top:=152);
.
.
.
end;
der sagt mir : Operator not applicable to this operand type

...im Grunde soll der nur durch Zufall ein Imageobjekt verschieben..kann mir wer sagen was ich da falsch mache oder mir ne Alternative aufzeigen?


Der operator "and" ist ein logischer operator. er dient dir z.b. in if-abfragen dazu, mehrere Werte abzufragen :

ausblenden Delphi-Quelltext
1:
2:
3:
 
If (a = 5and  (b = 3then
blub...


gruß
Horst_H
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1654
Erhaltene Danke: 244

WIN10,PuppyLinux
FreePascal,Lazarus
BeitragVerfasst: So 02.12.07 12:57 
Hallo,

vielleicht ist mehr eine einfache Zuweisung gemeint und kein logischer Vergleich.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
case Random(z) of 
0begin
   xxx.left:=96;
   xxx.Top:=64
   end;
1:begin..

end;//case
Altenativ
With XXX do 
  begin
  case Random(z) of 
    0begin
       left:=96;
       Top:=64
       end;
    1begin
       ....

    end;//case
  end;//with
Zorro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76

Win 2000, Win XP Pro
Delphi 7 Architect
BeitragVerfasst: Fr 07.12.07 18:43 
user profile iconvan RanDahlE hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
z:=4;
case Random(z) of
 0:(xxx.left:=96and (xxx.Top:=64);        
 1:(xxx.left:=192and (xxx.Top:=64);       
 2:(xxx.left:=296and (xxx.Top:=64);       
 3:(xxx.left:=400and (xxx.Top:=64);      
 4:(xxx.left:=96and (xxx.Top:=152);       
                   .
                   .
                   .  
end;

der sagt mir : Operator not applicable to this operand type


Der "and" Operator dient NICHT dazu, mehrere Befehle zu verknüpfen - dazu gibts begin und end.

Greetz
Zorro
Atreyu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137


Delphi 7 Enterprise
BeitragVerfasst: Fr 07.12.07 19:46 
Genau, wenn man begin und end hat, wozu dann noch "and". Ich glaube, viele lassen sich von mehreren Zeilen einschüchtern, man ist oft im Glauben, alles hinter einer Case-Zuweisung müsste in einer Zeile passieren.
Sinspin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1335
Erhaltene Danke: 118

Win 10
RIO, CE, Lazarus
BeitragVerfasst: Fr 07.12.07 20:17 
AND findet sich immer nur bei logischen Verknüpfungen.
So wie sie Beispielsweise in einer einfachen Verzweigung:
ausblenden Delphi-Quelltext
1:
2:
IF (a = 1AND (b = 1THEN
  c := 2;

oder einen Schleifenabbruch:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
WHILE (Sonne = 'scheint'AND (bernd = 'schläft'DO
BEGIN
  Spielen;
END;

oder bei einer logischen Zuweisung:
ausblenden Delphi-Quelltext
1:
result := a AND b AND c;					


In deinem Fall würde das dann wohl eher so aussehen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
z:=4;
case Random(z) of
 0 : begin 
       xxx.left:=96;
       xxx.Top:=64;
     end;
                   .
                   .
                   .  
end;

Wobei das mit deinem "z := 4" eh nicht ganz klappt.
Denn der Bereich, in dem sich die von Random() gelieferte Zahl befindet geht von 0..3! Also von 0..z-1.

_________________
Wir zerstören die Natur und Wälder der Erde. Wir töten wilde Tiere für Trophäen. Wir produzieren Lebewesen als Massenware um sie nach wenigen Monaten zu töten. Warum sollte unser aller Mutter, die Natur, nicht die gleichen Rechte haben?