Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

CADTenchy (TechnicalUser) (OP)
17 Aug 08 14:46

I'm trying to follow the example here:
http://www.swissdelphicenter.ch/article_data/ch21.pdf

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)

CADTenchy (TechnicalUser) (OP)
17 Aug 08 14:59

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)

whosrdaddy (Vendor)
17 Aug 08 15:06
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!

CADTenchy (TechnicalUser) (OP)
17 Aug 08 15:22

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:


Huh?

Steve (Delphi 2007 & XP)

whosrdaddy (Vendor)
18 Aug 08 3:18
show the whole demo (and also the dfm)

/Daddy

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

CADTenchy (TechnicalUser) (OP)
18 Aug 08 3:48

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)

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close