Autor Beitrag
Arbengie
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 66



BeitragVerfasst: Do 27.05.10 20:34 
Wo ist da der Fehler?! Vllt dumme Frage, aber ich finde Ihn einfach nicht :(

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.Image2Click(Sender: TObject);
begin
  If shoot = true then
  begin
    mediaplayer1.Play;
    Label1.Caption := IntToStr(StrToInt(Label1.Caption)+1);
    Image2.Left := RandomRange(10,520);
    Image2.Top := RandomRange(10,320);
  end;
  If If Label2.Caption <> '0' then
  begin
    Label2.Caption := IntToStr(StrToInt(Label2.Caption)-1);
  end
  Else If Label2.Caption = '0' then
  begin
    shoot := false;
  end;
[b][u]end;[/u][/b]


Fehler: [Error] uGame.pas(60): Type of expression must be BOOLEAN
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 27.05.10 21:02 
Der Vergleich mit Booleanwerten (z.B. if shift = true then) ist nicht nur unschön und unlogisch, sondern falsch.
Hier gibt es mal ein kleines Beispiel welches zeigt, wann es schief geht:
www.delphi-forum.de/....php?p=548760#548760
Mehr dazu steht hier:
www.delphi-treff.de/...olean-werten/page/4/
Und warum das auch vollkommen unlogisch ist, wird hier erklärt:
www.delphi-forum.de/....php?p=560637#560637

Ferner solltest Du bei Dir mal schauen, dass du die letzte Abfrage weglässt, weil dort ein reines Else logischer ist.

In Zeile 10 steht übrigens If If ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.