Autor Beitrag
THF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

Vista
Delphi 2005 professional
BeitragVerfasst: Mi 09.03.05 21:19 
Hallo,

Ich habe folgendes Problem:
Ich habe 2 for - Schleifen,
wenn in der untergeordneten Schleife ein Ereignis eintritt,
sollen beide Schleifen gestoppt werden.

Wenn ich break reinschreibe oder break;break; dann wird nur
die untergeordnete Schleife gestoppt ,
weil er zum zweiten break gar nicht kommt.
Oder ? ? ?
Beispiel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
 for i:= 1 to 10 do
      for j:= 1 to 10 do
begin
       if (i+j+x) =100
              then 
                  break;break;  
end;

Gruß

THF
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: Mi 09.03.05 21:23 
vielleicht so?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
for i:= 1 to 10 do
begin
  for j:= 1 to 10 do
    if (i+j+x) =100 then 
    begin
      abbruch:=True;
      break;
    end;

  if abbruch then break;
end;

Edit: Code korrigiert

_________________
We are, we were and will not be.
THF Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

Vista
Delphi 2005 professional
BeitragVerfasst: Mi 09.03.05 21:31 
Hallo Gausi,

so könnte es funktionieren,ich werde es mal ausprobieren.

Du hast das Problem verstanden.

Danke

Gruß
:P
THF
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Fr 11.03.05 11:56 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
 label ENDE;
 var i,j : integer;
begin
 for i:= 1 to 10 do
 begin
  for j:= 1 to 10 do
   if (i+j) =100 then
   begin
    goto ENDE;
   end;
 end;
 ENDE:
end;



MUHAHAHAHAHHA :shock: