Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jul : [D7 + Indy 9 -> 10] TBytes vs. TIdBytes

www.cryer.info
Managed Newsgroup Archive

[D7 + Indy 9 -> 10] TBytes vs. TIdBytes

Subject:[D7 + Indy 9 -> 10] TBytes vs. TIdBytes
Posted by:"Vincent Delporte" (justa..@acme.com)
Date:Wed, 12 Jul 2006 15:10:19

Hello

    I'm stuck with an error after upgrading from Indy 9 to Indy
10. Browsing the archives didn't solve this issue that other
encountered, so here it goes...

1. I followed the instructions in the KB "How do I install Indy into
Borland Delphi?" to uninstall Indy 9, and then ran Indy Install Plus
to install Indy 10.1.5. It worked OK as far as I can tell.

Next, I added a UDPServer widget in the form, and added some dummy
code for the OnUDPRead event:

-------- CODE----------
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TByte;
  ABinding: TIdSocketHandle);
begin

  ShowMessage('incoming');

end;
-------- CODE----------

=> In the Type section, on the line "procedure IdUDPServer1UDPRead",
Delphi shows error "[Error] Unit1.pas(15): Undeclared identifier:
'TBytes'".

2. The archives of this ng say that it's apparently a bug in Delphi,
and that I should try changing all occurences of TBytes to TIdBytes,
add IdGlobal and IdSocketHandle to the uses clause, and hit F9.

=> "Error/The IdUDPServer1UDPRead method referenced by
IdUDPServer1.OnUDPRead has an incompatible parameter list. Remove the
reference?"

Leaving IdGlobal and IdSocketHandle in the uses clause while changing
TIdBytes back to TBytes let me run the program, and respond to
incoming UDP packets.

3. However, when changing the even trigger code to this:

-------- CODE----------
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TBytes;
ABinding: TIdSocketHandle);
var
  LMsg: string;
begin
  SetLength(LMsg, AData.Size);
  AData.ReadBuffer(LMsg[1], Length(LMsg));
  Label1.Caption := TimeToStr(Time) + ' : ' + LMsg;
end;
-------- CODE----------

=> "SetLength(LMsg, AData.Size);" :
[Error] Unit1.pas(42): Record, object or class type required

So, I'm still stuck with TBytes and TIdBytes. Any idea?

Thank you.

Replies:

www.cryer.info
Managed Newsgroup Archive