Autor Beitrag
Hendi48
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Mi 18.07.07 13:27 
Hi,
ich habe einen Updater der der die neueste version und eine notice zu einem Client übermittelt. Leider klappt das mit dem notice senden nicht so es kommt immer: nil kann nicht zu TRicheditStrings zugewiesen werden.

mein code (ausschnitte):
Server:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
type
TestRecord = record 
   lines: TStrings;
  end;

  TForm2 = class(TForm)
[...]

procedure TForm2.ServerSocket1ClientWrite(Sender: TObject;
  Socket: TCustomWinSocket);
var
buffer: TestRecord;
begin

with Buffer do begin 
  lines := richedit1.lines;
end;

Socket.SendBuf(Buffer, SizeOf(Buffer));
Socket.Sendtext(Edit1.text);
end;

Client:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
type
  TestRecord = record 
   lines:  Tstrings;
  end;

[...]

procedure TForm2.ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
var
  aktuell: boolean;
  getbuffer: TestRecord;
begin
  aktuell:=false;
  label5.Caption:=Socket.ReceiveText;
  Application.ProcessMessages;
  aktuell:=label4.caption=label5.caption;
  if not aktuell then
    begin
      showmessage('OMG new version!');
    end;
  if aktuell then
    begin
      showmessage('You are using the latest version.');
    end;

  Socket.ReceiveBuf(GetBuffer, SizeOf(GetBuffer));

  with GetBuffer do begin
    RichEdit1.Lines:=lines;
  end

end;


Edit:
Wenn ich
ausblenden Delphi-Quelltext
1:
2:
3:
4:
with GetBuffer do begin
lines.SaveToFile('lol.txt');
//  RichEdit1.Lines:=lines;
end;

mach kommt ne access violation also kann es sein das der gar nix empfängt?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 18.07.07 14:55 
Moin!

user profile iconHendi48 hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
type
TestRecord = record 
   lines: TStrings;
  end;

Fehler-Klassiker, kuckst du in die FAQ. :mahn: :les: ;)

user profile iconHendi48 hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
with Buffer do begin 
  lines := richedit1.lines;
end;

Das ist komplett falsch, du kannst Objekte nicht durch Zuweisung der Zeiger kopieren, dazu gibt es .Assign()! :mahn: :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Mi 18.07.07 15:08 
hm also is ein record schlecht dafür geeignet..wie soll ich es denn sonst machen? Den text in eine .txt speichern lassen und dann zum client senden?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 18.07.07 15:10 
Moin!

Schau mal hier, das Problem dürfte ähnlich gelagert sein. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Mi 18.07.07 20:28 
hm das is mir zu kompliziert, ich lass es einfach von meiner homepage runterladen.
Trotzdem danke für die Hilfe!