Friso
Friso

Reputation: 2428

Why is TIdTextEncoding.Default undeclared?

I tried to build the first client project that I got from http://sourceforge.net/projects/indy10clieservr/ but it says that TIdTextEncoding and Default from line 62 are both undeclared. I haven't made any chances, so what could have caused this?

Full code: interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdGlobal;

type
  TClientForm = class(TForm)
    CheckBoxConnectDisconnet: TCheckBox;
    ButtonSendString: TButton;
    Edit1: TEdit;
    Memo1: TMemo;
    IdTCPClient1: TIdTCPClient;
    procedure CheckBoxConnectDisconnetClick(Sender: TObject);
    procedure ButtonSendStringClick(Sender: TObject);
    procedure IdTCPClient1Connected(Sender: TObject);
    procedure IdTCPClient1Disconnected(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  ClientForm: TClientForm;

implementation

{$R *.dfm}

{ TForm1 }

procedure TClientForm.ButtonSendStringClick(Sender: TObject);
var
  LLine: String;
begin

  IdTCPClient1.IOHandler.WriteLn(Edit1.Text, TIdTextEncoding.Default);
  Edit1.Text := '';
  LLine := IdTCPClient1.IOHandler.ReadLn();
  if ( LLine = 'OK' ) then
      Memo1.Lines.Add('Server says it has received your String');

end;

procedure TClientForm.CheckBoxConnectDisconnetClick(Sender: TObject);
begin
  if ( CheckBoxConnectDisconnet.Checked = True ) then
  begin
    IdTCPClient1.Host := '127.0.0.1';
    IdTCPClient1.Port := 6000;
    IdTCPClient1.Connect;
  end
  else
    IdTCPClient1.Disconnect;
end;

procedure TClientForm.IdTCPClient1Connected(Sender: TObject);
begin
  Memo1.Lines.Add('Client connected with server');
end;

procedure TClientForm.IdTCPClient1Disconnected(Sender: TObject);
begin
  Memo1.Lines.Add('Client disconnected from server');
end;

end.

Upvotes: 1

Views: 9369

Answers (1)

mjn
mjn

Reputation: 36654

This project lists only Delphi 2010, XE, and XE2 on the sourceforge home page so I guess that it has not been updated to newer Indy versions.

TIdTextEncoding was removed in Indy 10.6, as stated in the Indy ChangeLog blog:

Indy 10.6 has been released

the IdGlobal.TIdTextEncoding class has been replaced with a new IdGlobal.IIdTextEncoding refcounted interface that no longer depends on SysUtils.TEncoding (Embarcadero) or System.Text.Encoding (.NET) anymore (though there are wrappers provided if you still need to use them with Indy). Consequently, the IndyXXXEncoding() functions have been deprecated in favor of new IndyTextEncoding_XXX() functions.

Indy 10.6 introduced a new IndyTextEncoding_OSDefault() function as a replacement for TIdTextEncoding.Default. (See here)

Upvotes: 9

Related Questions