Results 1 to 3 of 3

Thread: Please need a little help(Out of range)

  1. #1
    Join Date
    Mar 2007
    Location
    Mars, I thought all men were from Mars.
    Posts
    513
    Mentioned
    7 Post(s)
    Quoted
    124 Post(s)

    Default Please need a little help(Out of range)

    I'm trying to make a procedure where when I mouse click a little red cross paints on smart to let me know where I clicked. As far as I can tell my code is all right. I've went over it like 50 times and can't seem to find the bug. Maybe an out side viewer can see what I can't seem to.

    Also if you know of a shorter more neat why of doing this please let me know.

    This is the error I keep getting: 'Error: Out Of Range at line 111'

    Simba Code:
    program new;
    {$DEFINE SMART}
    {$i srl/srl.scar}
    {$i SRL/SRL/misc/paintsmart.scar}
    var x,y:integer;
    procedure MousePaint(mousex, mousey, ranx, rany: Integer; left: Boolean);
    var
      CTPA :integer;
      TP:Tpoint;
      TPA:TPointArray;
    begin
      MMouse(mousex, mousey, ranx, rany);
      GetMousePos(x,y)
      TP := Point(x,y);
      SetLength(TPA,103)

    /////////////////////////////////////////////
    /////////////////////////////////////////////
      //Draw right
      for CTPA:= 0 to 9 do
      begin
       TPA[CTPA]:= TP;
       TP := point(TP.x+1,TP.y);
      end;
    ///////////////////////
      TP := Point(x,y-1);
      for CTPA:= 10 to 17 do
     begin
       TPA[CTPA]:= TP;
       TP := point(TP.x+1,TP.y);
      end;;
    ///////////////////////
       TP := Point(x,y+1);
      for CTPA:= 18 to 25 do
      begin
       TPA[CTPA]:= TP;
       TP := point(TP.x+1,TP.y);
      end;


    /////////////////////////////////////////////
    /////////////////////////////////////////////
      TP := Point(x,y);
      //Draw down
      for CTPA:= 26 to 35 do
      begin
       TPA[CTPA]:= TP;
       TP := point(TP.x,TP.y+1);
      end;
    ///////////////////////
      TP := Point(x+1,y);
      for CTPA:= 36 to 43 do
      begin
       TPA[CTPA]:= TP;
       TP := point(TP.x,TP.y+1);
      end;
    ///////////////////////
      TP := Point(x-1,y);
      for CTPA:= 44 to 51 do
      begin
       TPA[CTPA]:= TP;
       TP := point(TP.x,TP.y+1);
      end;


    /////////////////////////////////////////////
    /////////////////////////////////////////////
      TP := Point(x,y);
      //Draw left
      for CTPA:= 52 to 61 do
      begin
       TPA[CTPA]:= TP;
       TP := point(TP.x-1,TP.y);
      end;
    ///////////////////////
       TP := Point(x,y+1);
      for CTPA:= 62 to 69 do
      begin
       TPA[CTPA]:= TP;
       TP := point(TP.x-1,TP.y);
      end;
    ///////////////////////
       TP := Point(x,y-1);
      for CTPA:= 70 to 77 do
      begin
       TPA[CTPA]:= TP;
       TP := point(TP.x-1,TP.y);
      end;


    /////////////////////////////////////////////
    /////////////////////////////////////////////
      TP := Point(x,y);
      //Draw up
      for CTPA:= 78 to 87 do
      begin
       TPA[CTPA]:= TP;
       TP := point(TP.x,TP.y-1);
      end;
    ///////////////////////
       TP := Point(x+1,y);
      for CTPA:= 88 to 95 do
      begin
       TPA[CTPA]:= TP;
       TP := point(TP.x,TP.y-1);
      end;
    ///////////////////////
      TP := Point(x-1,y);
      for CTPA:= 96 to 103 do
     begin
       TPA[CTPA]:= TP;
       TP := point(TP.x,TP.y-1);
      end;

      Wait(60 + Random(30));
      SMART_DrawDotsEx(false,TPA,clRed);
      ClickMouse2(left);
    end;

    begin
    Smart_Server := 44;
    SetupSRL();
    MousePaint(100,100,0,0,true)
    end.

  2. #2
    Join Date
    Jun 2008
    Location
    United States
    Posts
    818
    Mentioned
    60 Post(s)
    Quoted
    90 Post(s)

    Default

    change
    Simba Code:
    for CTPA:= 96 to 103 do
    to
    Simba Code:
    for CTPA:= 96 to 102 do

    You set the length of your TPA to 103. Arrays start at 0. 0 to 103 is 104 values, but you set the length to 103 meaning you are only working with 103 values. You do not have a 104th value to mess with, thus, it is out of range.
    [10/14/13:19:03] <BenLand100> this is special relatively, just cleverly disguised with yachts

  3. #3
    Join Date
    Mar 2007
    Location
    Mars, I thought all men were from Mars.
    Posts
    513
    Mentioned
    7 Post(s)
    Quoted
    124 Post(s)

    Default

    ahh lol can't believe i missed that. Thanks

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
  •