Hi,
Could one of you experts look at my code please.
My program crashes after the first set of strings are added because -- I think -- the length is not updating.
The following is just a snipet.
type
   Detail = record
     Extra1, Extra2, Extra3, Extra4, Extra5, Extra6, Extra7, Extra8 :string
   end;

var
  Form1: TForm1;
head : array [0..7] of string = ('Extra1', 'Extra2', 'Extra3', 'Extra4','Extra5', 'Extra6', 'Extra7', 'Extra8');
  x : integer;
  y : integer;
  z : integer;
  w : integer;
  currentLength : integer;
  collection : array of Detail;
  information : array  of array of string;

procedure TForm1.MenuItemInputClick(Sender: TObject);
//initial setup
begin
     SetLength(collection,1);
     SetLength(information,8,1);
end;

procedure TForm1.ButtonNextClick(Sender: TObject);
begin
 // extend array lengths
       if Length(collection) < (y+1)then
       begin
       SetLength(collection, y+1);
       SetLength(information[x],y+1);
       end;

 // load array
       information[0,y] := TEdit1.Text;
       information[1,y] := TEdit2.Text;
       information[2,y] := TEdit3.Text;
       information[3,y] := TEdit4.Text;
       information[4,y] := TEdit5.Text;
       information[5,y] := TEdit6.Text;
       information[6,y] := TEdit7.Text;
       information[7,y] := TEdit8.Text;

//display aray lenghts
       z := (Length(collection));
       LabelResult.Caption := inttostr(z);
       w := (Length(information));
       LabelResult1.Caption := inttostr(w);
 //write to listbox
       for  x := 0 to 7 do
         begin
         ListBox1.Items.Add(head[x] + ' ' + information[x,y] + ' ');
         end;
  //clear edit boxes
       TEdit1.Text := ' ';
       TEdit2.Text := ' ';
       TEdit3.Text := ' ';
       TEdit4.Text := ' ';
       TEdit5.Text := ' ';
       TEdit6.Text := ' ';
       TEdit7.Text := ' ';
       TEdit8.Text := ' ';
       y := y + 1
end;

After the first set of strings are added, I get this error message:-

Project protection raised exception class 'External: SIGSEGV'.

I'm sure it's just me not understanding how arrays should be manipulated,
Look forward to any help
Paul
--
---This message has been sent using Thunderbird on kubuntu---

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to