Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
ampelStatus := 0;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
ampelRot: array[0..5] of TShape;
ampelGelb: array[0..5] of TShape;
ampelGruen: array[0..5] of TShape;
i: Integer;
begin
for i := 0 to 5 do
begin
ampelRot[i] := TShape(FindComponent('rot'+inttostr(i+1)));
ampelGelb[i] := TShape(FindComponent('gelb'+inttostr(i+1)));
ampelGruen[i] := TShape(FindComponent('gruen'+inttostr(i+1)));
end;
case ampelStatus of
0: begin
for i := 0 to 5 do
begin
ampelRot[i].Brush.Color := clRed;
ampelGelb[i].Brush.Color := clBlack;
ampelGruen[i].Brush.Color := clBlack;
end;
timer1.Interval := 6000;
ampelStatus := 1;
end;
1: begin
for i := 0 to 5 do
begin
ampelRot[i].Brush.Color := clRed;
ampelGelb[i].Brush.Color := clYellow;
ampelGruen[i].Brush.Color := clBlack;
end;
timer1.Interval := 2000;
ampelStatus := 2;
end;
2: begin
for i := 0 to 5 do
begin
ampelRot[i].Brush.Color := clBlack;
ampelGelb[i].Brush.Color := clBlack;
ampelGruen[i].Brush.Color := clGreen;
end;
timer1.Interval := 6000;
ampelStatus := 3;
end;
3: begin
for i := 0 to 5 do
begin
ampelRot[i].Brush.Color := clBlack;
ampelGelb[i].Brush.Color := clYellow;
ampelGruen[i].Brush.Color := clBlack;
end;
timer1.Interval := 2000;
ampelStatus := 0;
end;
end;
end;
Entweder mit exit arbeiten oder rückwärts anfangen...