Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi TIdFTP: SendCmd überschreiben (https://www.delphipraxis.net/147838-tidftp-sendcmd-ueberschreiben.html)

Angel4585 17. Feb 2010 11:28


TIdFTP: SendCmd überschreiben
 
Hallo,

ich stelle gerade um von D2005 auf D2010 und hab jetzt das Problem, dass bei einer Komponente die von TIdFTP abgeleitet ist, das Überschreiben von SendCmd nichtmehr akzeptiert wird:

Delphi-Quellcode:
TMyFTP = class(TIdFTP)
  private
    .
    .
  public
    function SendCmd(AOut: string; const AResponse: array of SmallInt) : SmallInt; override;
  end;
end;

function TMyFTP.SendCmd(AOut: string; const AResponse: array of SmallInt) : SmallInt;
begin
.
.
end;
Ich versteh jetzt nicht genau warum, TIdFTP selbst hat zwar kein SendCmd, allerdings hat TIdTCPConnection dieses SendCmd, also sollte es doch funktionieren. Oder wo denk ich hier falsch?

Edit: fast vergessen, die Fehlermeldung:
[DCC Fehler] UMyFTP.pas(94): E2137 Methode 'SendCmd' nicht in Basisklasse gefunden

Assertor 30. Mär 2010 16:53

Re: TIdFTP: SendCmd überschreiben
 
Hallo Angel4585,

etwas spät, aber hier die allgemeingültige Lösung für alle DPler:

Zitat:

Zitat von Angel4585
ich stelle gerade um von D2005 auf D2010 und hab jetzt das Problem, dass bei einer Komponente die von TIdFTP abgeleitet ist, das Überschreiben von SendCmd nichtmehr akzeptiert wird:

Delphi-Quellcode:
TMyFTP = class(TIdFTP)
  private
    .
    .
  public
    function SendCmd(AOut: string; const AResponse: array of SmallInt) : SmallInt; override;
  end;
end;

function TMyFTP.SendCmd(AOut: string; const AResponse: array of SmallInt) : SmallInt;
begin
.
.
end;
Ich versteh jetzt nicht genau warum, TIdFTP selbst hat zwar kein SendCmd, allerdings hat TIdTCPConnection dieses SendCmd, also sollte es doch funktionieren. Oder wo denk ich hier falsch?

Edit: fast vergessen, die Fehlermeldung:
[DCC Fehler] UMyFTP.pas(94): E2137 Methode 'SendCmd' nicht in Basisklasse gefunden

SendCmd() wurde in Delphi 2009 und 2010 wg. Unicode angepasst. Du mußt die Methode so überschreiben, wie sie tatsächlich vorhanden ist.

In D2009/2010 ist dies (siehe IdTCPConnection.pas):
Delphi-Quellcode:
function SendCmd(AOut: string; const AResponse: SmallInt = -1;
  AEncoding: TIdTextEncoding = nil): SmallInt; overload;
function SendCmd(AOut: string; const AResponse: array of SmallInt;
  AEncoding: TIdTextEncoding = nil): SmallInt; overload; virtual;
function SendCmd(AOut: string; const AResponse: string;
  AEncoding: TIdTextEncoding = nil): string; overload;
In Deinem Fall also:
Delphi-Quellcode:
TMyFTP = class(TIdFTP)
  private
    .
    .
  public
    function SendCmd(AOut: string; const AResponse: array of SmallInt;
      AEncoding: TIdTextEncoding = nil): SmallInt; override;
  end;
end;

function TMyFTP.SendCmd(AOut: string; const AResponse: array of SmallInt;
  AEncoding: TIdTextEncoding = nil): SmallInt;
begin
.
.
end;
Alternativ kannst Du für Abwärtskompatibilität das ganze in IFDEFs packen:
Delphi-Quellcode:
TMyFTP = class(TIdFTP)
  private
    .
    .
  public
    function SendCmd(AOut: string; const AResponse: array of SmallInt;
      {$IFDEF UNICODE}AEncoding: TIdTextEncoding = nil{$ENDIF}): SmallInt; override;
  end;
end;

function TMyFTP.SendCmd(AOut: string; const AResponse: array of SmallInt;
  {$IFDEF UNICODE}AEncoding: TIdTextEncoding = nil{$ENDIF}): SmallInt;
begin
.
.
end;
Gruß,
Assertor


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:56 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz