Access Violation When Creating Matrix Objects

Problem

I am having some difficulty with matrix assignments. The following code produces access violation errors:

procedure TForm1.XXX (Sender: TObject);

var
  userdata : Tmatrix;

begin
userdata.Create(5,5);
userdata.elem[1,1] := 2.332; <--- this assignment causes the problems
....
Solution

You made a mistake in creating the matrix. The correct statement should read like this:

...
begin
userdata := TMatrix.Create (5,5); <--- mind the difference !
userdata.elem[1,1] := 2.332; <--- no problems any more
...

 


Last Update: 2006-01-13