Autor Beitrag
seelachs
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Sa 16.05.09 18:05 
Hallo ihr,
ich bräuchte da mal eure Hilfe und zwar muss ich ein paar Hausaufgaben machen und ich weiß nicht wo der Fehler ist, da ich mich damit nicht so gut auskenne. Ich soll eine Ampelkreuzung programmieren mit 4 Ampeln die jeweils 4 Phasen haben ( Rot, Rot Gelb , Grün, Gelb ) und die sollen da richtig geschaltet werden . ( Dies soll mit Timern geschehen )
Könnt ihr mir vielleicht helfen ? Ich würde mich riesig über Antworten freuen. Sieht euch das Rot makierte an, dort müsste der Fehler sein !



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:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
interface

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

type//, ExtCtrls, Controls, StdCtrls, Classes
  TForm1 = class(TForm)
    Shape1: TShape;
    Shape2: TShape;
    shpRed1: TShape;
    shpYellow1: TShape;
    shpGreen1: TShape;
    shpYellow2: TShape;
    shpRed2: TShape;
    shpGreen2: TShape;
    Shape9: TShape;
    Shape10: TShape;
    Shape11: TShape;
    Shape12: TShape;
    Shape13: TShape;
    Shape14: TShape;
    Shape15: TShape;
    Shape16: TShape;
    Shape17: TShape;
    Shape18: TShape;
    Shape19: TShape;
    Shape20: TShape;
    Shape21: TShape;
    Shape22: TShape;
    Shape23: TShape;
    Shape24: TShape;
    Shape25: TShape;
    Shape26: TShape;
    Shape27: TShape;
    Shape28: TShape;
    Shape29: TShape;
    Shape30: TShape;
    Shape32: TShape;
    Shape33: TShape;
    Shape34: TShape;
    Shape35: TShape;
    Shape36: TShape;
    Shape37: TShape;
    Shape38: TShape;
    Shape39: TShape;
    Shape31: TShape;
    Shape40: TShape;
    Shape41: TShape;
    Shape42: TShape;
    Shape43: TShape;
    Shape44: TShape;
    Shape45: TShape;
    Shape46: TShape;
    Shape47: TShape;
    Shape48: TShape;
    Shape49: TShape;
    Shape50: TShape;
    Shape51: TShape;
    Shape52: TShape;
    Shape53: TShape;
    Shape54: TShape;
    Shape55: TShape;
    Shape56: TShape;
    Shape57: TShape;
    Shape59: TShape;
    Shape60: TShape;
    Shape61: TShape;
    Shape62: TShape;
    Shape63: TShape;
    Shape64: TShape;
    Shape65: TShape;
    Shape66: TShape;
    Shape67: TShape;
    Shape68: TShape;
    Button1: TButton;
    Timer1: TTimer;
    shpRed3: TShape;
    shpYellow3: TShape;
    shpGreen3: TShape;
    shpRed4: TShape;
    shpYellow4: TShape;
    shpGreen4: TShape;
    Timer2: TTimer;
    procedure shpRed2MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.shpRed2MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Close;
end;

procedure TForm1.Timer1Timer(Sender: TObject);

begin

   if shpGreen2.Brush.Color = clblack then
   begin
   Timer1.interval       := 3000;
   shpRed2.Brush.Color    := clred;
   shpYellow2.Brush.Color := clblack;
   shpGreen2.Brush.Color  := clnone;
   shpRed1.Brush.Color    := clred;
   shpYellow1.Brush.Color := clblack;
   shpGreen1.Brush.Color  := clnone;
   end

   else if shpYellow2.Brush.Color = clblack then
   begin
   Timer1.interval       := 3000;
   shpRed2.Brush.Color    := clred;
   shpYellow2.Brush.Color := clyellow;
   shpGreen2.Brush.Color  := clnone;
   shpRed1.Brush.Color    := clred;
   shpYellow1.Brush.Color := clyellow;
   shpGreen1.Brush.Color  := clnone;
    end
     else if shpRed2.Brush.Color = clred then
   begin
   Timer1.interval       := 3000;
   shpRed2.Brush.Color    := clnone;
   shpYellow2.Brush.Color := clnone;
   shpGreen2.Brush.Color  := cllime;
   shpRed1.Brush.Color    := clnone;

   shpYellow1.Brush.Color := clnone;
   shpGreen1.Brush.Color  := cllime;
   end
   else if shpGreen2.Brush.Color = cllime then
      begin
      Timer1.interval       := 3000;
      shpRed2.Brush.Color    := clblack;
      shpYellow2.Brush.Color := clyellow;
      shpGreen2.Brush.Color  := clblack;
      shpRed1.Brush.Color    := clblack;
      shpYellow1.Brush.Color := clyellow;
      shpGreen1.Brush.Color  := clblack;
      end
    end;


    procedure TForm1.Timer2Timer(Sender: TObject);
begin
if shpRed4.Brush.Color = clred then
   begin
   Timer1.interval       := 3000;
   shpRed2.Brush.Color    := clnone;
   shpYellow2.Brush.Color := clnone;
   shpGreen2.Brush.Color  := cllime;
   shpRed1.Brush.Color    := clnone;
   shpYellow1.Brush.Color := clnone;
   shpGreen1.Brush.Color  := cllime;
   end
   else if shpGreen4.Brush.Color = cllime then
      begin
      Timer1.interval       := 3000;
      shpRed2.Brush.Color    := clblack;
      shpYellow2.Brush.Color := clyellow;
      shpGreen2.Brush.Color  := clblack;
      shpRed1.Brush.Color    := clblack;
      shpYellow1.Brush.Color := clyellow;
      shpGreen1.Brush.Color  := clblack;
      end
     else if shpGreen4.Brush.Color = clblack then
   begin
   Timer1.interval       := 3000;
   shpRed2.Brush.Color    := clred;
   shpYellow2.Brush.Color := clblack;
   shpGreen2.Brush.Color  := clnone;
   shpRed1.Brush.Color    := clred;
   shpYellow1.Brush.Color := clblack;
   shpGreen1.Brush.Color  := clnone;
   end

   else if shpYellow4.Brush.Color = clblack then
   begin
   Timer1.interval       := 3000;
   shpRed2.Brush.Color    := clred;
   shpYellow2.Brush.Color := clyellow;
   shpGreen2.Brush.Color  := clnone;
   shpRed1.Brush.Color    := clred;
   shpYellow1.Brush.Color := clyellow;
   shpGreen1.Brush.Color  := clnone;
    end
end;

end.



Ampel Senkrecht Funktioniert. Ampel Waagerecht macht nichts.

Mfg seelachs ;)

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
Einloggen, um Attachments anzusehen!
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Sa 16.05.09 19:03 
Ich sehe leider nichts rot markiertes.
Also ich würde eher einzelne Int(eger)-Werte für die Phasenabhandlung nehmen.
Also eben, dass Du die Phasen bei Ampel Eins zum Beispiel so setzt:
Case AmpelPhase of
0:Rot
1:Rot
2:Gelb
3:Grün
4:Grün

Damit könntest Du dann die Ampelschaltung einfach so abhandeln, indem Du dann in einer Timer-Schaltung schreibst:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
if AmpelPhase<4 then
    inc(AmpelPhase)
else
    AmpelPhase:=0

Und ich denke mal, dass Du die Ampeln beide zur gleichen Zeit in der Gelbphase haben möchtest - oder?
Das hieße dann ja, dass Du Dann einfach nur bei der zweiten Ampel die Phasen umtauschen musst (aber die gleiche Variable nimmst!):
0:Grün
1:Grün
2:Gelb
3:Rot
4:Rot

Damit könntest Du doch abfragen:
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 AmpelPhase of
0:begin
  MachDieAmpelDerStrasseEinsRot();
  MachDieAmpelDerStrasseZweiGruen();
  end;
1:begin
  MachDieAmpelDerStrasseEinsRot();
  MachDieAmpelDerStrasseZweiGruen();
  end;
2:begin
  MachDieAmpelDerStrasseEinsGelb();
  MachDieAmpelDerStrasseZweiGelb();
  end;
3:begin
  MachDieAmpelDerStrasseZweiRot();
  MachDieAmpelDerStrasseEinsGrün()
  end;
4:begin
  MachDieAmpelDerStrasseZweiRot();
  MachDieAmpelDerStrasseEinsGruen()
  end;
seelachs Threadstarter
Hält's aus hier
Beiträge: 11



BeitragVerfasst: So 17.05.09 21:27 
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:
begin
if shpRed4.Brush.Color = clred then
   begin
   Timer1.interval       := 3000;
   shpRed2.Brush.Color    := clnone;
   shpYellow2.Brush.Color := clnone;
   shpGreen2.Brush.Color  := cllime;
   shpRed1.Brush.Color    := clnone;
   shpYellow1.Brush.Color := clnone;
   shpGreen1.Brush.Color  := cllime;
   end
   else if shpGreen4.Brush.Color = cllime then
      begin
      Timer1.interval       := 3000;
      shpRed2.Brush.Color    := clblack;
      shpYellow2.Brush.Color := clyellow;
      shpGreen2.Brush.Color  := clblack;
      shpRed1.Brush.Color    := clblack;
      shpYellow1.Brush.Color := clyellow;
      shpGreen1.Brush.Color  := clblack;
      end
     else if shpGreen4.Brush.Color = clblack then
   begin
   Timer1.interval       := 3000;
   shpRed2.Brush.Color    := clred;
   shpYellow2.Brush.Color := clblack;
   shpGreen2.Brush.Color  := clnone;
   shpRed1.Brush.Color    := clred;
   shpYellow1.Brush.Color := clblack;
   shpGreen1.Brush.Color  := clnone;
   end

   else if shpYellow4.Brush.Color = clblack then
   begin
   Timer1.interval       := 3000;
   shpRed2.Brush.Color    := clred;
   shpYellow2.Brush.Color := clyellow;
   shpGreen2.Brush.Color  := clnone;
   shpRed1.Brush.Color    := clred;
   shpYellow1.Brush.Color := clyellow;
   shpGreen1.Brush.Color  := clnone;
    end
end;

end.


Hier befindet sich der Fehler.

Moderiert von user profile iconKha: Delphi-Tags hinzugefügt

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

Sobald die Ampel 1 auf Rot ist muss Ampel 2 Grün sein. Dann muss Ampel 1 RotGelb werden und Ampel 2 Gelb. Dann muss Ampel 1 Grün werden und Ampel 2 Rot.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10184
Erhaltene Danke: 1259

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 17.05.09 23:31 
Moin und :welcome: im Forum!

Schau mal hier, vielleicht kommst du damit weiter. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
oldmax
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 380


D3 Prof, D4 Prof
BeitragVerfasst: Mo 18.05.09 13:09 
Hi
Wenn du schon eine Ampelkreuzung (Namentlich) im Kopf hast, warum suchst du nicht erst einmal danach. Dieses Thema scheint in regelmäßigen Abschnitten eine beliebte Hausaufgabe zu sein. Mittlerweile gibt es sehr viel Hilfe, was den Aufbau einer Ampelschaltung betrifft und auch jede Menge Code dazu. Auch ich hab vor ca. 1 Jahr bereits die Vorgehnsweise erläutert, so das sich daraus ein brauchbares Programm gestalten kann. Also, such mal nach Ampelkreuzung oder nach oldmax. Da wird dir bestimmt was brauchbares geliefert.
Gruß oldmax

_________________
Zier dich nich so, ich krieg dich schon....
seelachs Threadstarter
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Mi 20.05.09 19:50 
So hab es geschafft. Jetz muss ich es nur noch schaffen, das ein Auto dort fährt. Kennt sich einer damit aus ? Wie man sowas macht ?
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Mi 20.05.09 21:32 
Naja, Du könntest es ja erst mal mit Panels machen, denen Du eine (beliebige) Farbe gibst und dann, wenn sie fahren dürfen, entsprechend
ausblenden Delphi-Quelltext
1:
2:
PanelAutoVonOben.Top:=PanelAutoVonOben.Top+1//für ein runter fahrendes Auto
PanelAutoVonUnten.Top:=PanelAutoVonUnten.Top-1;//für ein hoch fahrendes Auto

und wenn die andere Straße grün hat, dann die anderen fahren lassen:
ausblenden Delphi-Quelltext
1:
2:
PanelAutoVonLinks.Left:=PanelAutoVonLinks.Left+1;//für ein nach rechts fahrendes Auto
PanelAutoVonRechts.Left:=PanelAutoVonRechts.Left-1;//für ein nach links fahrendes Auto

Wobei die Namen der Panels ja eigentlich egal sind. Sie müssen nur auf jeden Fall unterschiedlich heißen damit sie eindeutig ansprechbar sind!
Standard-Namen sind aber auch möglich, also wie zum Beispiel:
ausblenden Delphi-Quelltext
1:
Panel1.Left:=Panel1.Left-1;					

Nur dadurch kommt man dann schnell mal durcheinander - also sollte man es sich nach Möglichkeit erst gar nicht angewöhnen!
seelachs Threadstarter
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Do 21.05.09 14:23 
Hm. Ich versuch ma.

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

Ich versteh das nicht. Bewegt er sich dann von alleine oder wie muss ich das machen ?
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Do 21.05.09 17:39 
Nein, das ganze müsstest Du dann in einem anderen, zweiten Timer-Event aufrufen.
Also einen (bzw. zwei - für die andere kreuzende Straße ja auch) Timer in das Programm bauen und dann auf OnTimer doppelklicken, dann müsste ja eine Procedure erscheinen, in dei Du dann schreibst:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
if AmpelPhase=0 or AmpelPhase=1 then //heißt, wenn die eine Straße grün hat:
   begin
   PanelAutoVonOben.Top:=PanelAutoVonOben.Top+1//für ein in die eine Richtung fahrendes Auto
   PanelAutoVonUnten.Top:=PanelAutoVonUnten.Top-1;//für ein in die Gegen-Richtung fahrendes Auto
   end;
else if AmpelPhase=3 or AmpelPhase=4 then //heißt, wenn die andere Straße grün hat:
   begin
   PanelAutoVonLinks.Left:=PanelAutoVonLinks.Left+1;//für ein in die eine Richtung fahrendes Auto
   AutoPanelAutoVonRechts.Left:=PanelAutoVonRechts.Left-1;//für ein in die Gegen-Richtung fahrendes Auto
   end;

Alles verstanden?


Zuletzt bearbeitet von ffgorcky am Do 21.05.09 17:54, insgesamt 1-mal bearbeitet
seelachs Threadstarter
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Do 21.05.09 17:53 
Also so ?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.Timer4Timer(Sender: TObject);

if AmpelPhase=0 or AmpelPhase=1 then
   begin
   PanelAutoVonOben.Top:=PanelAutoVonOben.Top+1;
   AutoPanelAutoVonUnten.Top:=PanelAutoVonUnten.Top-1;
   end;
procedure TForm1.Timer3Timer(Sender: TObject);
else if AmpelPhase=3 or AmpelPhase=4 then
   begin
   PanelAutoVonLinks.Left:=PanelAutoVonLinks.Left+1;
   AutoPanelAutoVonRechts.Left:=PanelAutoVonRechts.Left-1;

end;

Er zeigt mir dann aber ein Fehler bei ( if AmpelPhase=0 or AmpelPhase=1 then )

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Do 21.05.09 17:57 
Wahrscheinlich beanstandet er, dass er diese Variable vonobennachunten nicht kennt.
Hast Du diese Variable denn schon als int deklariert? (unter var der Form)
- Müsstest Du ja eigentlich, wenn diese Abfrage geht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
Case AmpelPhase of
0:begin
  MachDieAmpelDerStrasseEinsRot();
  MachDieAmpelDerStrasseZweiGruen();


Zuletzt bearbeitet von ffgorcky am Do 21.05.09 17:59, insgesamt 1-mal bearbeitet
seelachs Threadstarter
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Do 21.05.09 17:58 
var
Form1: TForm1;

ja so.
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Do 21.05.09 18:00 
ich sehe noch nichts von der Zeile
ausblenden Delphi-Quelltext
1:
AmpelPhase:integer;					
seelachs Threadstarter
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Do 21.05.09 18:05 
ausblenden Delphi-Quelltext
1:
2:
procedure TForm1.shpRed2MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);


ich hab es so wo muss ich dann AmpelPhase hinmachen ?

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Do 21.05.09 18:09 
Da Du sie ja jetzt in mehreren Proceduren brauchst, musst Du sie dann jetzt ja doch im Formular unter private deklarieren.


Zuletzt bearbeitet von ffgorcky am Do 21.05.09 18:14, insgesamt 1-mal bearbeitet
seelachs Threadstarter
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Do 21.05.09 18:14 
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:
interface

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

type//, ExtCtrls, Controls, StdCtrls, Classes
  TForm1 = class(TForm)
    Shape1: TShape;
    Shape2: TShape;
    shpRed1: TShape;
    shpYellow1: TShape;
    shpGreen1: TShape;
    shpYellow2: TShape;
    shpRed2: TShape;
    shpGreen2: TShape;
    Shape9: TShape;
    Shape10: TShape;
    Shape11: TShape;
    Shape12: TShape;
    Shape13: TShape;
    Shape14: TShape;
    Shape15: TShape;
    Shape16: TShape;
    Shape17: TShape;
    Shape18: TShape;
    Shape19: TShape;
    Shape20: TShape;
    Shape21: TShape;
    Shape22: TShape;
    Shape23: TShape;
    Shape24: TShape;
    Shape25: TShape;
    Shape26: TShape;
    Shape27: TShape;
    Shape28: TShape;
    Shape29: TShape;
    Shape30: TShape;
    Shape32: TShape;
    Shape33: TShape;
    Shape34: TShape;
    Shape35: TShape;
    Shape36: TShape;
    Shape37: TShape;
    Shape38: TShape;
    Shape39: TShape;
    Shape31: TShape;
    Shape40: TShape;
    Shape41: TShape;
    Shape42: TShape;
    Shape43: TShape;
    Shape44: TShape;
    Shape45: TShape;
    Shape46: TShape;
    Shape47: TShape;
    Shape48: TShape;
    Shape49: TShape;
    Shape50: TShape;
    Shape51: TShape;
    Shape52: TShape;
    Shape53: TShape;
    Shape54: TShape;
    Shape55: TShape;
    Shape56: TShape;
    Shape57: TShape;
    Shape59: TShape;
    Shape60: TShape;
    Shape61: TShape;
    Shape62: TShape;
    Shape63: TShape;
    Shape64: TShape;
    Shape65: TShape;
    Shape66: TShape;
    Shape67: TShape;
    Shape68: TShape;
    Button1: TButton;
    Timer1: TTimer;
    shpRed3: TShape;
    shpYellow3: TShape;
    shpGreen3: TShape;
    shpRed4: TShape;
    shpYellow4: TShape;
    shpGreen4: TShape;
    Timer2: TTimer;
    Panel1: TPanel;
    Timer4: TTimer;
    Panel2: TPanel;
    Panel3: TPanel;
    Panel4: TPanel;
    Timer3: TTimer;
    procedure shpRed2MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure Timer5Timer(Sender: TObject);
    procedure PanelAutoVonObenContextPopup(Sender: TObject; MousePos: TPoint;
      var Handled: Boolean);
    procedure Panel1Click(Sender: TObject);
    procedure Timer4Timer(Sender: TObject);
    procedure Timer3Timer(Sender: TObject);
    procedure Timer6Timer(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.shpRed2MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);

So sieht es bei mir gerade aus.

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
oldmax
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 380


D3 Prof, D4 Prof
BeitragVerfasst: So 24.05.09 12:53 
Hi
Zitat:

Er zeigt mir dann aber ein Fehler bei ( if AmpelPhase=0 or AmpelPhase=1 then )

Ich weiß nicht, ob dein Problem mit der If- Abfrage gelöst ist, aber ich hab nix diesbezüglich gelesen.
Daher geh ich mal darauf ein.
Wenn du eine Abfrage in dieser Form benutzt, mußt du die Vergleiche in Klammern setzen.
ausblenden Delphi-Quelltext
1:
if (AmpelPhase=0or (AmpelPhase=1then					

Noch ein kleiner Hinweis zum Einrücken.
Dein Code ist nicht gerade leicht lesbar, wein Begin - End Bereiche nicht besonders erkannt werden können.
Es mag sein, das sich hier auch teilweise Experten nicht ganz einig sind, wie es richtig ist, aber nach meiner Erfahrung bin ich mit folgendem Aufbau gut zurechtgekommen
Beispiele...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
if <Bedingung> then
begin
  tu dies
  und das
end else
begin
  oder tu das eine 
  und das andere
end;


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
For i = 0 to 100 do
begin
  if <Bedingung> then
  begin
    tu dies
    und das
  end;
  tu dann noch was
end;


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
Case i of 1Begin
               mach was
             end;
          2: mach nur das
          3Begin
               mach hier mehr
             end;
end;  // End Case


Ich hab mir angewöhnt, grundsätzlich Begin eine eigene Zeile zu spendieren, außer bei Case, da kommt Begin hinter den Doppelpunkt.
Danach wird eingerückt (2 Spaces), dann kommt der Block und end wir wieder unter das Begin zurückgeschoben. Dadurch sind die gültigen Codeblöcke leicht zu erkennen. Bei vielen Verschachtelungen ist ein Kommentar wie bei End case sinnvoll und man weiß sofort welcher Codeblock endet.
Gruß oldmax

_________________
Zier dich nich so, ich krieg dich schon....
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: So 24.05.09 13:25 
Hast Du die Variable denn jetzt so deklariert?
ausblenden Delphi-Quelltext
1:
2:
3:
private
{ Private-Deklarationen }
AmpelPhase:Integer;

Dein Quelltext hört leider bei dieser Zeile auf:
ausblenden Delphi-Quelltext
1:
procedure TForm1.shpRed2MouseDown(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);					

Könntest Du denn noch mal "die andere Hälfte" hier reinstellen?
Oder das gesamte Projekt als *.zip irgendwo (z.B. auf Deiner Webseite) hinterlegen und einen Link
(Auf diese Art: '[URL]'HierDeinLink,ohneDieHochkommas'[/URL]') dazu hier reinschreiben?

Oder hat sich das Thema jetzt erledigt? - Dann markiere es doch bitte so!
Danke!
seelachs Threadstarter
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Mo 25.05.09 22:48 
Ich lad ma alles hier hoch.
Wenn du es schaffen solltest es zum laufen zu bringen, wäre ich dir mega Dankbar.

Moderiert von user profile iconNarses: Archiv als Anhang hochgeladen.
Einloggen, um Attachments anzusehen!
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Di 26.05.09 09:40 
So, jetzt fahren schon mal die auf der senkrechten Straße.
Hilft Dir das weiter?
Oder soll ich Dir gleich das gesammte Projekt gelöst hier reinstellen?
Dann brauchst Du ja nichts mehr selber schreiben - wodurch Du doch aber das ganze erst so wirklich lernen würdest!
Einloggen, um Attachments anzusehen!