Autor Beitrag
LinzerASK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 135

WIN XP
Delphi 4, Delphi 2005
BeitragVerfasst: Mo 30.10.06 10:36 
sodale dass programm:
Einloggen, um Attachments anzusehen!
LinzerASK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 135

WIN XP
Delphi 4, Delphi 2005
BeitragVerfasst: Mo 30.10.06 12:54 
@mkinzler hast du schon was raus finden können
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 30.10.06 13:43 
Du hast den begin..end - Block bei der For-Schleife vergessen.
So sollte es grundsätzlich gehen
p
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:
rocedure TForm1.Button5Click(Sender: TObject);
var i:integer;
begin
   case spinedit2.value of
     0:
     begin
        q := Erster;
        Erster := Erster^.Nachbar;
        Dispose( q);
      end;
     1:
     begin
        p := Erster^.Nachbar;
        q := p^.Nachbar;
        p^.Nachbar := q^.Nachbar;
        Dispose( q);
     end;
   else
       p:=erster;
        for i:=2 to spinedit2.value-1 do //bis vor die einzufügende Stelle    nach hinten gehen
        begin
            p:=p^.nachbar;
            q:= p^.nachbar; //q ist Eintrag der gelöscht werden soll                                                                               w
            p^.nachbar:= q^.Nachbar; //Vorgänger zeigt nun auf Nachfolger
            Dispose(q); // Löscht q
        end;
  end;
end;

_________________
Markus Kinzler.
LinzerASK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 135

WIN XP
Delphi 4, Delphi 2005
BeitragVerfasst: Mo 30.10.06 14:28 
kann ich das ganue auch ohne case of machen
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 30.10.06 14:33 
Du könntest den case durch gestaffelte If-Anweisungen ersetzen, aber warum?

_________________
Markus Kinzler.
LinzerASK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 135

WIN XP
Delphi 4, Delphi 2005
BeitragVerfasst: Mo 30.10.06 17:47 
ja schon aber das mit dem case scheint mir sehr kompliziert!
und vor allem funktioniert das nicht!

wenn ich bei spinedit auf 1 stelle wird der 3 eintrag gelöscht...
LinzerASK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 135

WIN XP
Delphi 4, Delphi 2005
BeitragVerfasst: Mo 30.10.06 18:05 
lade dir mal das programm herunter, und füge deine prozedur ein!

ich wette mir dir, dass es nicht richtig arbeitet!

mfg
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 30.10.06 18:11 
mein Code ist irrtümlich für einen Startindex von 0 geschrieben, bei einem Startindex von 1 sieht es natürlich anders aus;
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm1.Button5Click(Sender: TObject);
var i:integer;
begin
   if spinedit2.value = 1 then 
     begin
        q := Erster;
        Erster := Erster^.Nachbar;
        Dispose( q);
      end
    else
    begin
       p:=erster;
        for i:=2 to spinedit2.value-1 do //bis vor die einzufügende Stelle    nach hinten gehen
        begin
            p:=p^.nachbar;
            q:= p^.nachbar; //q ist Eintrag der gelöscht werden soll                                                                               w
            p^.nachbar:= q^.Nachbar; //Vorgänger zeigt nun auf Nachfolger
            Dispose(q); // Löscht q
        end;
  end;
end

getiipt und nicht getestet (werde das aber nachher Nachholen)

_________________
Markus Kinzler.
LinzerASK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 135

WIN XP
Delphi 4, Delphi 2005
BeitragVerfasst: Mo 30.10.06 18:16 
es funzt trotzdem nicht! ehrlich, es wird nur der erste rausgelöscht! die anderen gehen einfach nicht raus! :D
LinzerASK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 135

WIN XP
Delphi 4, Delphi 2005
BeitragVerfasst: Mo 30.10.06 19:40 
@mkinzler


hast du es schon bei deinem progi probiert?
LinzerASK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 135

WIN XP
Delphi 4, Delphi 2005
BeitragVerfasst: Di 31.10.06 09:12 
@mkinzler

wie schaud es aus?

mfg