Results 1 to 5 of 5

Thread: Out of Range

  1. #1
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Out of Range

    It's a simple error, i know it! I can't figure it out though..
    SCAR Code:
    function LoadTree: boolean;
    var
    Color : TIntegerArray;
    begin
      Color := [1, 2, 3];
      for i := 0 to High(Color) do
      Writeln('Searching for tree color : '+ IntToStr(Color[i]));
      if FindColorTolerance(x, y, Color[i], msx1, msy1, msx2, msy2, 10) then Result := True;
      Writeln('Found : '+  BoolToStr(Result));
    end;

    I get this:
    SCAR Code:
    [Runtime Error] : Out Of Range in line 65 in script C:\Program Files (x86)\SCAR 3.20\Scripts\Box Trapper.scar

    PS: Box trapper is a weird name for a woodcutter

  2. #2
    Join Date
    Oct 2007
    Location
    Denmark
    Posts
    409
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    U missed a begin end
    Also, you should have it exit when it finds the tree.
    SCAR Code:
    function LoadTree: Boolean;
    var
      Color : TIntegerArray;
      H, i, x, y: Integer;
    begin
      Color := [1, 2, 3];
      H := High(Color);
      for i := 0 to H do
      begin
        Writeln('Searching for tree color : '+ IntToStr(Color[i]));
        if FindColorTolerance(x, y, Color[i], msx1, msy1, msx2, msy2, 10) then
        begin
          Result := True;
          Writeln('Found : '+  BoolToStr(Result));
          Exit;
        end;
      end;
    end;

  3. #3
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    function LoadTree: boolean;
    var
    Color : TIntegerArray;
    begin
      Color := [1, 2, 3];
      for i := 0 to High(Color) do
      Begin
        Writeln('Searching for tree color : '+ IntToStr(Color[i]));
        if FindColorTolerance(x, y, Color[i], msx1, msy1, msx2, msy2, 10) then Result := True;
        Writeln('Found : '+  BoolToStr(Result));
      end;
    end;

    Fixed .

    You needed a begin after the For to Do statement becuase it always only reads one line down, unless an If statement is attached to it


    Frt beat me, but mine uses one less begin and end

  4. #4
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    See, i told you i was an easy to fix error, lol. I'm so ashamed of not being able to fix it. -cries in corner-

  5. #5
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    SCAR Code:
    function LoadTree: boolean;
    var
    Color : TIntegerArray;
    begin
      Color := [1, 2, 3];
      for i := 0 to High(Color) do
      Begin
        Writeln('Searching for tree color : '+ IntToStr(Color[i]));
        if FindColorTolerance(x, y, Color[i], msx1, msy1, msx2, msy2, 10) then Result := True;
        Writeln('Found : '+  BoolToStr(Result));
      end;
    end;

    Fixed .

    You needed a begin after the For to Do statement becuase it always only reads one line down, unless an If statement is attached to it


    Frt beat me, but mine uses one less begin and end
    Yours doesn't exit...

Thread Information

Users Browsing this Thread

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

Posting Permissions

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