Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi: Missing Operator or Semicolon

I am using Indy 10(TIdTcpServer) and I get the following error:

[DCC Error] MainForm.pas(88): E2066 Missing operator or semicolon

When trying to run this code:

procedure TForm1.SendMessage(Data: String; Client: Integer);
var
  List: TList;
  AContext: TIdContext;
begin
  List := idTcpServer1.Contexts.LockList;
  AContext(List[0]).Connection.IOHandler.WriteLn(Data);  // Line 88
end;

I cannot figure out what I am missing; any help?

like image 716
user1580845 Avatar asked Mar 16 '26 09:03

user1580845


1 Answers

While I can't explain the error you're getting, your code is totally wrong.

Change it to:

procedure TForm1.SendMessage(Data: String; Client: Integer);
var
  List: TList;
  AContext: TIdContext;
begin
  List := idTcpServer1.Contexts.LockList;
  AContext := TIdContext(List[0]);
  AContext.Connection.IOHandler.WriteLn(Data);
end;

Your bad use of the typecast with a non-type may be confusing the compiler. If that doesn't solve it, please edit your question to add more code around what you've posted (the dozen or so lines before what you've posted would help).

like image 96
Ken White Avatar answered Mar 19 '26 08:03

Ken White