Einzelnen Beitrag anzeigen

Thorben86

Registriert seit: 20. Nov 2003
Ort: Brühl
365 Beiträge
 
Delphi 2005 Personal
 
#7

Re: warten bis aufgerufene Procedure beendet ist

  Alt 20. Okt 2004, 14:21
Hier die 3 code-Teile, aber eigentlich wäre es mir schon lieber, wenn das irgendwie sofort abbricht und den ausgangszustand einnimmt, da das ziehmlich dähmlich aussieht, wenn das noch kurzzeitig da ist, müsste doch möglich sein, dass der das nicht weiterverschiebt, sondern direkt abbricht, oder?.
Bei Matzes Programm klappt das auch, allerdings verwendet der findcomponent und keine dynamischen Komponentne.

Der Aufruf:
Delphi-Quellcode:
procedure TForm1.m_textausgabeClick(Sender: TObject);
begin
Stapel[1].Anzahl := sp_scheibenzahl.value;
anzahl := 0;
memo1.Clear;
e_schritte.Clear;
Abbruch:=false;
Berechnen(sp_scheibenzahl.Value,1,3,2);
end;
Das verschieben:
Delphi-Quellcode:
procedure TForm1.Animation(Startstapel,Zielstapel:Integer);
begin
Shape1[Startstapel,Stapel[Startstapel].Anzahl].Left := Stapel[Zielstapel].left - (Shape1[Startstapel,Stapel[Startstapel].Anzahl].Width div 2);
Shape1[Startstapel,Stapel[Startstapel].Anzahl].Top := Stapel[Zielstapel].Top - (15 * (Stapel[Zielstapel].Anzahl+1)) ;
Shape1[Zielstapel,Stapel[Zielstapel].Anzahl+1]:= Shape1[Startstapel,Stapel[Startstapel].Anzahl] ;
inc(Stapel[Startstapel].Anzahl,-1);
inc(Stapel[Zielstapel].Anzahl);
end;
Startaufstellung:
Delphi-Quellcode:
procedure TForm1.Startaufstellung(Scheiben:Shortint);
var i:integer;
anzahl,p,o:integer;
begin
  for p:=1 to 3 do
  for o:=1 to Stapel[p].Anzahl do
  Shape1[p,o].free ;

  Stapel[1].Anzahl := 0;
  scheibenzahl:=0;

  for i := 1 to Scheiben do
     begin
     Shape1[1,i] := TShape.Create(self);
    Shape1[1,i].Parent := Form1;
    shape1[1,i].Width := 100 -((100 div Scheiben)*(I-1));
    shape1[1,i].Height := 15;
    shape1[1,i].Top := Stapel[Startstapel].Top - (15 * (Stapel[Startstapel].Anzahl+1));
    shape1[1,i].Left := Stapel[Startstapel].left - (shape1[1,i].Width div 2);
    shape1[1,i].Shape := stRoundRect;
    inc(Stapel[Startstapel].Anzahl);
    inc(Anzahl);
    inc(Scheibenzahl);
      end;
end;
Edit, teil vergessen.
Delphi-Quellcode:
procedure TForm1.Berechnen(n: integer; Startstapel, Zielstapel, Hilfsstapel: integer);
var pause: integer;
begin

  if (n > 0) and (not Abbruch) then
  begin
    Berechnen(n-1, Startstapel, Hilfsstapel, Zielstapel);
    inc(Anzahl);
    Memo1.Lines.Add(IntToStr(Startstapel) + ' ---> ' + IntToStr(Zielstapel));
    E_schritte.Text := IntToStr(Anzahl);

   Animation(Startstapel, Zielstapel);

   pause := StrToInt(e_pause.Text);
   Delay(pause);
   Berechnen(n-1, Hilfsstapel , Zielstapel,Startstapel );
  end;
  
  {if Abbruch = true then
  begin
  startaufstellung(sp_scheibenzahl.Value);
  end;    }

  
end;
  Mit Zitat antworten Zitat