Autor Beitrag
g1o2k4
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: Mo 12.03.07 20:02 
ausblenden Delphi-Quelltext
1:
2:
3:
for i:=1 to ende do //ich möchte in zweier schritten arbeiten also 1,3,5,7,ende
begin
end;


wie geht das ?
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Mo 12.03.07 20:07 
Geht nicht mit einer for-Schleife

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
i := 1;
while i < 11 do
begin
...
inc(i, 2);
end;
Dunkel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 682

Mac OS X Snow Leopard
Xcode 3.1
BeitragVerfasst: Mo 12.03.07 21:26 
Geht auch mit einer for-Schleife! (ob das schön ist, darüber könnte man streiten)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var
  i: integer;
begin
  for i:=1 to 11 do
    begin
      if (i mod 2) = 1 then
        begin
          // mach was, wenn i ungerade ist
        end;
    end;   
end;
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: Mo 12.03.07 21:30 
Ich würde das prinzipiell so lösen, wenn ich bei der for-Schleife bleiben wollte:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
 for i := 1 to (ende Div 2) do
begin
  //machwas mit i*2
end;

_________________
We are, we were and will not be.
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 13.03.07 15:39 
Da fehlt was...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button1Click(Sender: TObject);
var I,ende :integer;
begin
ende:=20;   //nur zum Testen
for i := 0 to (ende Div 2) do
begin
  //machwas mit i*2+1 !!!
Label4.Caption:= IntToStr(i*2+1);
Application.ProcessMessages;
sleep(1000);   //nur zum Testen
end;
end;