Autor Beitrag
AndyM79
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20

Win XP Prof.
Delphi 5 Prof. & BDS 2006
BeitragVerfasst: Mo 23.10.06 08:23 
Hallo,

ich habe da ein ganz seltsames Ding, bei mir ist 5 größer als 5!?
habe folgende procedure:
ausblenden 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:
procedure PrintA52xA6AbfuellerNr(Abfueller:PChar;StartNr,Anzahl:Integer;Wiederholung:Boolean);
var
  i1 : integer;
begin
  i1 := StartNr;
  qr := Tqr.Create(nil);
  with qr do
  try
    while not (i1 > Anzahl) do
    begin
      QRLabelAbfueller1.Caption := Abfueller;
      QRLabelAbfueller2.Caption := Abfueller;
      QRLabelNr1.Caption := InttoStr(i1);
      if Wiederholung then
      begin
        QRLabelNr2.Caption := InttoStr(i1);
      end else
      begin
        inc(i1);
        QRLabelNr2.Caption := InttoStr(i1);
      end;
      Etikett.Preview;
      inc(i1);
    end;
  finally
    Free;
  end;
end;


wenn ich die Procedure aufrufe zB so

PrintA52xA6AbfuellerNr('Andreas Möller',1,5,true);

sollte doch normalerweise die Schleife 5 mal durchlaufen werden.
nach 4 mal bricht sie aber ab. Wenn ich im Debugger anhalte und mir i1 und Anzahl anzeigen lassen sind beide 5, also sollte die Schleife dann doch durchlaufen, wird aber übersprungen bzw beendet? Warum? 5 ist doch nicht größer als 5.

_________________
Grüße aus dem schönen Westerwald
Andy
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 23.10.06 08:27 
Es müßte >= Anzahl heißen, da die Whileschleife ja ne Entry-Condition-Loop ist.

_________________
Markus Kinzler.
freak4fun
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 604
Erhaltene Danke: 4

Win 7 Pro
VS 2013 Express, Delphi, C#, PHP, Java
BeitragVerfasst: Mo 23.10.06 08:30 
Wenn Wiederholung false ist wird inc(i1); ausgeführt und immer inc(i1); , dadurch wird die schleife verkürzt. Wenn also Wiederholung 1 mal false ist wird die schleife 4 mal ausgeführt. :)

_________________
"Ich werde auf GAR KEINEN Fall…!" - "Keks?" - "Okay, ich tu's."
i++; // zaehler i um 1 erhoehen
AndyM79 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20

Win XP Prof.
Delphi 5 Prof. & BDS 2006
BeitragVerfasst: Mo 23.10.06 08:33 
Titel: Danke
Danke für die Schnellen antworten.
funktioniert auch jetzt, manchmal sieht man den Wald vor lauter Bäumen nicht :-)

_________________
Grüße aus dem schönen Westerwald
Andy