Results 1 to 5 of 5

Thread: Havent been here in a while, Most Likely a stupid mistake...

  1. #1
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Havent been here in a while, Most Likely a stupid mistake...

    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

  2. #2
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wow, SRL has changed... What happened to the days when people raced to help others?

  3. #3
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Try this instead. It compiles and runs for me:

    EDIT: Am I racing fast enough?

    SCAR Code:
    program New;
    type
      Matrix = record
        Name: string;
        Elements: Array of Array of Integer;
        Rows, Collums: Integer;
      end;
    var
      Happy: Matrix;
      AMatrix: T2DIntArray;
    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
      SetLength(AMatrix, 3);
      AMatrix[0] := [1, 2, 3];
      AMatrix[1] := [1, 2, 3];
      AMatrix[2] := [1, 2, 3];
      Happy := DefineMatrix(AMatrix, 'Happy');
      WriteMatrix(Happy);
    end.
    :-)

  4. #4
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    SCAR Code:
    Happy := DefineMatrix([TIntegerArray([1, 2, 3]), TIntegerArray([1, 2, 3]), TIntegerArray([1, 2, 3])], 'Happy');
    Not your fault, it was a SCAR bug.

  5. #5
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ok thanks! Im glad its SCAR, not me, thats going crazy

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Havent been on forums for awhile, had a Question?
    By runeland1 in forum SRL Site Discussion
    Replies: 6
    Last Post: 11-19-2007, 04:25 AM
  2. mistake
    By sweetleaf in forum RuneScape News and General
    Replies: 0
    Last Post: 06-14-2007, 01:57 AM
  3. mistake in SCAR
    By Killerdou in forum News and General
    Replies: 4
    Last Post: 02-24-2007, 05:57 AM
  4. Tiny Mistake
    By TheGodfather in forum OSR Help
    Replies: 5
    Last Post: 02-13-2007, 07:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •