Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Anweisung für FOR-Variable (https://www.delphipraxis.net/11572-anweisung-fuer-variable.html)

devnull 9. Nov 2003 21:37


Anweisung für FOR-Variable
 
Hi,
ich hab ne normale FOR-Schleife und möchte innerhalb der Schleife die Schleifenvariable [i] erhören. Das geht aber nich ?

Delphi-Quellcode:
  for i := 1 to 100 do begin
      if i = 50 then i := 70;
  end;
Weis da jemand was ?

devnull

sakura 9. Nov 2003 21:39

Re: Anweisung für FOR-Variable
 
Da musst Du auf eine while-Schleife ausweichen.

Delphi-Quellcode:
I := 1;
while I <= 100 do
begin
  if I = 50 then
    I := 70;
  Inc(I);
end;
...:cat:...

Chewie 9. Nov 2003 21:40

Re: Anweisung für FOR-Variable
 
Richtig, das geht nicht. Zumindest nicht ohne schmutzige Tricks.
Aber eine for-Schleife ist ja extra dazu da, dass man sich nicht selbst um die Zählvariable kümmern muss. Was hast du denn vor?

Stanlay Hanks 9. Nov 2003 21:43

Re: Anweisung für FOR-Variable
 
Ich vermute mal, du möchtest den Bereich von 50 bis 70 überspringen, oder? Dann musst du wirklick eine While Schleife nehmen, wie Sakura (...:cat:...) schon sagte. :wink:

Man liest sich, Stanlay :hi:

Matze 9. Nov 2003 21:49

Re: Anweisung für FOR-Variable
 
Ich stell hier auch mal eine Frage ;)
Sie passt so gut hier her:

Gibt es nicht sowas, wäre praktisch:
Delphi-Quellcode:
for (i:=1 to 50) and (i:=70 to 100) do

devnull 9. Nov 2003 21:56

Re: Anweisung für FOR-Variable
 
Ok danke, die while-Schleife hat den Durchburch gebracht ...
Naja, ich versuche aus einer Zeile einzelne Information herauszunehmen:

Delphi-Quellcode:
  ;;NAME;VERSION;SIZE;DESCRIPTION;LINK;
So sieht die Zeile aus !
nochmal danke

devnull

Chewie 9. Nov 2003 21:56

Re: Anweisung für FOR-Variable
 
So was gibts:
Delphi-Quellcode:
for i := 1 to 50 do //
for i := 70 to 100 do //
:wink:

Matze 9. Nov 2003 21:57

Re: Anweisung für FOR-Variable
 
@Chewie: stimmt :wall:

War eine blöde Frage von mir.

czapie 9. Nov 2003 22:18

Re: Anweisung für FOR-Variable
 
@chewie

Schmutzige Tricks? Erläutere doch bitte ein bißchen weiter.
Czapie

sakura 9. Nov 2003 22:30

Re: Anweisung für FOR-Variable
 
So gehts (in Assmebler):

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
begin
  for I := 1 to 100 do
  begin
    asm
      cmp ebx, 50
      jnz @@1
      mov ebx, 70
      @@1:
    end;
    ListBox1.Items.Add(IntToStr(I));
  end;
end;
...:cat:...


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:48 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz