Autor Beitrag
Sorryman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52



BeitragVerfasst: Mo 24.11.03 08:15 
Hallo!

Ich hab in einem Record ein Array liegen! Wenn ich später auf das Array
zugreifen will erscheint eine Fehlermeldung (Zugriffsverletzung).
Einzelheiten poste ich hier jetzt mal:

ausblenden volle Höhe 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:
33:
34:
35:
type
  TCommBlock = record   // the Communication Block used in both parts
(Server+Client)
                 Command,
                 MyUserName,                 // the sender of the
message
                 MyComputerName,             // Name of the sender
                 IP,
                 Msg,                        // the message itself
                 ReceiverName: string[100];  // name of receiver
                 DatumZeit:  TDateTime;       // Zeit der aktuellsten
HostListe
                 ClientList: array [1..2] of TStringList;
               end;
 
 
 
var
  HostBlock: TCommBlock;
 
implementation
 
procedure TfrmNetViewer.UpdateClientList();
var
  i: integer;
  ListItem: TListItem;
  HostBlockt: TCommBlock;
begin
  for i := 0 to RemoteListe.Items.Count-1 do
  begin
    ListItem := RemoteListe.Items.Item[i];
    HostBlock.ClientList[1].Add(ListItem.Caption);
    HostBlock.ClientList[2].Add(ListItem.SubItems.CommaText);
  end;
end;


Warum gibt er mit an der Stelle
"HostBlock.ClientList[1].Add(ListItem.Caption);" eine Fehlermeldung?
Kann mir da jemand helfen?
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mo 24.11.03 08:22 
Hallo,

wo erzeugst du denn deine Stringlisten?
irgendwo mußt du
ausblenden Delphi-Quelltext
1:
ClientList[X]:=Tstringlist.create;					

für jedes deiner Arrayelemente haben. und das free nicht vergessen

Meiner Meinung kommst du besser, wenn du das nicht als record machst sondern als Klasse und deine Stringlisten im constructor erzeugst und destructor wieder freigibst

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Sorryman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52



BeitragVerfasst: Mo 24.11.03 09:12 
Die hab ich im OnCreate der Form stehen... kann es sein das es daran liegt?
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mo 24.11.03 09:44 
Sorryman hat folgendes geschrieben:
Die hab ich im OnCreate der Form stehen... kann es sein das es daran liegt?

poste das mal bitte

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Sorryman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52



BeitragVerfasst: Di 25.11.03 21:54 
ausblenden Quelltext
1:
2:
3:
4:
5:
procedure TfrmNetViewer.FormCreate(Sender: TObject);
begin
   HostBlock.ClientList[1] := TStringList.Create;
   HostBlock.ClientList[2] := TStringList.Create;
end;
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mi 26.11.03 09:44 
hmmm, komisch. Ich denke daß du irgendwo auf eine nichtinitialisierte Variable zugreifst.
Zitat:

HostBlockt: TCommBlock;
begin
for i := 0 to RemoteListe.Items.Count-1 do
begin
ListItem := RemoteListe.Items.Item[i];
...

hostblockt:=hostblock wäre in deinemFall aber verkehrt. Hast du sowas irgendow in deinem code und gibst anschließend die Stringlisten von Hostblock frei?

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)