Thema: Delphi Variable als Zeiger?

Einzelnen Beitrag anzeigen

neomic
(Gast)

n/a Beiträge
 
#10

Re: Variable als Zeiger?

  Alt 23. Sep 2007, 15:13
Ich finde die Idee gut...

Aber ich habe noch nen paar Probleme mit dem umsetzen:

Delphi-Quellcode:
procedure TSteuerung.NeuesAuto(pArt:Integer);
var Auto:TAuto;
begin
        // Auto erstellen
        case pArt of
                0:Auto:=TAutoVonUnten.Create(kForm,hAmpel[pArt]);
                1:Auto:=TAutoVonRechts.Create(kForm,hAmpel[pArt]);
                2:Auto:=TAutoVonOben.Create(kForm,hAmpel[pArt]);
                3:Auto:=TAutoVonLinks.Create(kForm,hAmpel[pArt]);
        end;

        // Auto zuweisen
        hAuto[pArt].Add(Auto);

        // Vordermann zuweisen
        if hAuto[pArt].Count>0 then
        hAuto[pArt].Last.SetzeAuto(hAuto[pArt].Items[hAuto[pArt].Count-1])
        else hAuto[pArt].Last.SetzeAuto(nil);
end;
Der erkennt hAuto[pArt].Last nicht als TAuto ("Undeclared identifier: 'SetzeAuto'")

Was kann ich tun?


edit: Oh ich glaub ich hab vergessen zu casten


edit2: Soweit ans laufen bekommen, nur das SetzeAuto immer nil zuweißt...

Delphi-Quellcode:
procedure TSteuerung.NeuesAuto(pArt:Integer);
var Auto,Auto2:TAuto;
var i:Integer;
begin
        // Auto erstellen
        case pArt of
                0:Auto:=TAutoVonUnten.Create(kForm,hAmpel[pArt]);
                1:Auto:=TAutoVonRechts.Create(kForm,hAmpel[pArt]);
                2:Auto:=TAutoVonOben.Create(kForm,hAmpel[pArt]);
                3:Auto:=TAutoVonLinks.Create(kForm,hAmpel[pArt]);
        end;

        // Auto zuweisen
        i:=hAuto[pArt].Add(Auto);

        // Vordermann suchen
        if i>0 then Auto2:=TAuto(hAuto[pArt].Items[i-1])
        else Auto2:=nil;

        // Vordermann zuweisen
        TAuto(hAuto[pArt].Items[i]).SetzeAuto(Auto2);
end;

Sieht einer den Fehler? o.0
  Mit Zitat antworten Zitat