Добрый день! пытаюсь обработать сообщения чата.
unit yadro;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IdUDPClient,
IdBaseComponent, IdComponent, IdUDPBase, IdUDPServer, FMX.StdCtrls, FMX.Edit,
FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, IdGlobal, IdSocketHandle,
FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf,
FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Phys, FireDAC.Stan.Pool,
FireDAC.Stan.Async, FireDAC.Phys.MSAcc, FireDAC.Phys.MSAccDef,
FireDAC.FMXUI.Wait, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf,
FireDAC.DApt, System.Rtti, FMX.Grid.Style, Data.Bind.EngExt,
Fmx.Bind.DBEngExt, Fmx.Bind.Grid, System.Bindings.Outputs, Fmx.Bind.Editors,
Data.Bind.Components, Data.Bind.Grid, Data.Bind.DBScope, FMX.Grid, Data.DB,
FireDAC.Comp.DataSet, FireDAC.Comp.Client;
type
TForm2 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
IdUDPServer1: TIdUDPServer;
Button2: TButton;
Button3: TButton;
Label2: TLabel;
Timer1: TTimer;
FDManager1: TFDManager;
FDConnection1: TFDConnection;
FDQuery1: TFDQuery;
DataSource1: TDataSource;
StringGrid1: TStringGrid;
BindSourceDB1: TBindSourceDB;
BindingsList1: TBindingsList;
LinkGridToDataSourceBindSourceDB1: TLinkGridToDataSource;
Edit2: TEdit;
procedure IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure Edit2Validating(Sender: TObject; var Text: string);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
S:string;
s1,s2,s3:String;
implementation
{$R *.fmx}
procedure TForm2.Button2Click(Sender: TObject);
begin
Form2.IdUDPServer1.Active:=true;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
Form2.IdUDPServer1.Active:=false;
end;
procedure TForm2.Edit2Validating(Sender: TObject; var Text: string);
begin
s3:= edit1.Text;
s2:= edit1.Text;
s1:= edit1.Text;
s1:= delete(edit1.Text,1,4);
s2:= delete(edit1.Text,1,4);
end;
procedure TForm2.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
var
ss:TStringStream; //сохранять буквы будем тут
s,buff:String; //вспомогательные переменные
begin
ss:=TStringStream.create(''); //создаем пустую строку
ss.write(adata[0],length(adata)); //записываем в нее данные из потока байт
s:=ss.DataString; //преобразовываем ее в текст
ss:=TStringStream.create(''); //создаем пустую строку
ss.write(adata[0],length(adata)); //записываем в нее данные из потока байт
s:=ss.DataString; //преобразовываем ее в текст
Memo1.Lines.Add(s); // если кракоз¤бры то пробуем Utf8ToAnsi и т д (но у мен¤ и так работает)
Edit1.Text:=s;
ss.free;//очищаем строку от мусора
end;
procedure TForm2.Timer1Timer(Sender: TObject);
begin
if form2.IdUDPServer1.Active=true then
begin
label2.Text:='Server On - port 8488';
end
else
label2.Text:='Server Off';
end;
end.
Выдаеттакую ошибку:
dcc64 command line for "Server.dpr"
c:\program files (x86)\embarcadero\studio\20.0\bin\dcc64.exe -$O- -$W+ --no-config -M -Q -TX.exe -AGenerics.Collections=System.Generics.Collections;
Generics.Defaults=System.Generics.Defaults;WinTypes=Winapi.Windows;WinProcs=Winapi.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE -DDEBUG
-E.\Win64\Debug -I"c:\program files (x86)\embarcadero\studio\20.0\lib\Win64\debug";"c:\program files (x86)\embarcadero\studio\20.0\lib\Win64\release";
C:\Users\Arthas\Documents\Embarcadero\Studio\20.0\Imports;"c:\program files (x86)\embarcadero\studio\20.0\Imports";
C:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\Win64;"c:\program files (x86)\embarcadero\studio\20.0\include"
-LEC:\Users\Public\Documents\Embarcadero\Studio\20.0\Bpl\Win64 -LNC:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\Win64 -NU.\Win64\Debug
-NSWinapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;System;Xml;Data;Datasnap;Web;Soap; -O"c:\program files
(x86)\embarcadero\studio\20.0\lib\Win64\release";C:\Users\Arthas\Documents\Embarcadero\Studio\20.0\Imports;"c:\program files
(x86)\embarcadero\studio\20.0\Imports";C:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\Win64;"c:\program files
(x86)\embarcadero\studio\20.0\include" -R"c:\program files (x86)\embarcadero\studio\20.0\lib\Win64\release";
C:\Users\Arthas\Documents\Embarcadero\Studio\20.0\Imports;"c:\program files (x86)\embarcadero\studio\20.0\Imports";
C:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\Win64;"c:\program files (x86)\embarcadero\studio\20.0\include" -U"c:\program files
(x86)\embarcadero\studio\20.0\lib\Win64\debug";"c:\program files (x86)\embarcadero\studio\20.0\lib\Win64\release";
C:\Users\Arthas\Documents\Embarcadero\Studio\20.0\Imports;"c:\program files (x86)\embarcadero\studio\20.0\Imports";
C:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\Win64;"c:\program files (x86)\embarcadero\studio\20.0\include" -V -VN -VR
-NBC:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\Win64 -NHC:\Users\Public\Documents\Embarcadero\Studio\20.0\hpp\Win64 -NO.\Win64\Debug
Server.dpr
[dcc64 Error] yadro.pas(76): E2197 Constant object cannot be passed as var parameter
[dcc64 Error] yadro.pas(77): E2197 Constant object cannot be passed as var parameter
[dcc64 Error] yadro.pas(44): E2065 Unsatisfied forward or external declaration: 'TForm2.Timer2Timer'
[dcc64 Fatal Error] F2063 Could not compile used unit 'yadro.pas'
Failed
Elapsed time: 00:00:00.6