Im writing a series of Matrix fuctions (
). I am getting an error that is very depressing because it is a sign of noobishness.
SCAR Code:
program New;
type
Matrix = record
Name: string;
Elements: Array of Array of Integer;
Rows, Collums: Integer;
end;
var
Happy: Matrix;
function DefineMatrix(Values: T2DIntArray; Name: string): Matrix;
var
i, x, y, Rows, Collums: Integer;
begin
Result.Rows:=GetArrayLength(Values);
Result.Collums:=GetArrayLength(Values[1]);
SetArrayLength(Result.Elements, Result.Rows);
for x:=0 to Result.Rows-1 do
SetArrayLength(Result.Elements[i], Result.Collums);
Result.Elements:=Values;
Result.Name:=Name;
end;
procedure WriteMatrix(M: Matrix);
var
i, a: Integer;
Row: array of string;
begin
WriteLn('Matrix '+ M.Name);
WriteLn('Dimentions (Rows x Collums) = ' + IntToStr(M.Rows)+ ' x '
+IntToStr(M.Collums));
SetArrayLength(Row, M.Rows);
for i:=0 to M.Rows - 1 do
begin
Row[i]:= '[';
for a:=0 to M.Collums - 1 do
Row[i]:=Row[i]+ ' ' + IntToStr(M.Elements[i][a]) + ' ';
a:=0;
WriteLn(Row[i] + ']');
end;
end;
begin
Happy := DefineMatrix([[1, 2, 3], [1, 2, 3], [1, 2, 3]], 'Happy');
WriteMatrix(Happy);
end.
[Runtime Error] : Type Mismatch in line 42 in script C:\Program Files\SCAR 3.12c\Scripts\Matrices.scar
Type Mismatch = not good 
but its a runtime error.... Im confused
Thanks