Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with Indy TCP components

Status
Not open for further replies.

CADTenchy

Technical User
Dec 12, 2007
237
GB
I'm trying to follow the example here:

but right at the outset I'm falling over with the onexecute procedure.

Firstly, if I double click the event to create the procedure, as I normally do I get this:
Code:
procedure TSDIAppForm.IdTCPServer1Execute(AContext: TIdContext);

instead of as the example says:
Code:
procedure TSDIAppForm.IdTCPServer1Execute(AThread: TIdPeerThread);

both of which (I if manually create the second) are showing an undeclared identifier on both TIdContext and TIdPeerThread.

I note the date on the demo is fairly old, have the Indy components changed, or is there a problem with my install, missing components?
If the tutorial is outdated for my Delphi 2007 Indy palette, does anyone know some recent ones?

Here is my entire code:
Code:
unit SDIMAIN;

interface

uses Windows, Classes, Graphics, Forms, Controls, 
  StdCtrls, Buttons, ExtCtrls, ComCtrls, StdActns,
  ActnList, ToolWin, IdBaseComponent, IdComponent, IdCustomTCPServer,
  IdTCPServer;

type
  TSDIAppForm = class(TForm)
    StatusBar: TStatusBar;
    IdTCPServer1: TIdTCPServer;
    procedure IdTCPServer1Execute(AContext: TIdContext);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  SDIAppForm: TSDIAppForm;

implementation

uses about;

{$R *.dfm}

procedure TSDIAppForm.IdTCPServer1Execute(AContext: TIdContext);
begin
// TidContext is 'undeclared identifier' ?
end;

end.


Steve (Delphi 2007 & XP)
 

OK, I found another example direct from Indy, and could see I need this added to the uses of my prog:
Code:
IdContext


Steve (Delphi 2007 & XP)
 
TIdPeerThread = Indy 9, TIdContext = Indy 10. the demos are old and were never updated to Indy10. changing TIdPeerThread to TIdContext will solve most problems.

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks Daddy, that's valuable info!

I am still getting an error at compile time though now.

Here is my OnExecute:
Code:
procedure TSDIAppForm.IdTCPServer1Execute(AContext: TIdContext);
var
s: string;
i: integer;
begin
  with AContext.Connection.IOHandler do
    try
      WriteLn('Type an integer and ENTER');
      s := ReadLn;
      try
        i := StrToInt(s);
        WriteLn(s + ' squared is ' + IntToStr(i*i));
      except
        WriteLn(s + ' is not an integer.');
      end;
    finally
      AContext.Connection.Disconnect;
    end;
end;

but I am getting the error:
onexecuteerror.gif


Huh?

Steve (Delphi 2007 & XP)
 
show the whole demo (and also the dfm)

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 

The start of a new day here sorted things out.
After spending last night comparing the working demo to my test prog line by line, to see some cunning difference between the two and failing, including examining all files in the project folders, today I spotted it very quickly.

For some reason, despite my double clicking next to the event in the IDE to create the procedure, the OnExecute event name was blank when I checked it. Pasting the procedure name in fixed it.

This is odd, and has never happened to me before!


Steve (Delphi 2007 & XP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top