Results 1 to 10 of 10

Thread: Out of rang error

  1. #1
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default Out of rang error

    Simba Code:
    Function Teleport(Where: String): Boolean;  //LS //Yeah I know its an include but I added some stuff
    Var
    Loc: TStringArray;
    Points: TPointArray;
    i,cts: Integer;
    Begin
    If(Not(LoggedIn))Then Exit;
    GameTab(tab_magic);
    Result := GameTab(tab_magic);
    If Result Then
     Begin
      FindHomeTeleport(x,y);
      HumanMMouse(x,y, 0,0);
      ClickMouse2(True);
      Writeln('Clicked Home Teleprot');
      Wait(1000 +Random(500));
      If LodestoneScreen Then
      Begin
        Writeln('Found LodeStone Screen!');
        Wait(3000 +Random(500));
      End;

      Begin
        Loc := ['Catherby', 'Ardougne', 'Lumbridge'];
        Points := [Point(223, 181), Point(167, 211), Point(327, 243)];

      For i := 0 To 3 Do
        If Capitalize(Where) = Loc[I] Then
        Begin
          MMouse(Points[I].X, Points[I].Y, 2, 2);
          Writeln('Teleporting');
          //Writeln('Teleporting to' +Loc':'+IntToStr(i+1)));
          If (WaitUptextMulti(['Teleport', 'ele', 'ort', 'lepo', 'epor'], 400)) Then
          Begin
            Wait(1000+Random(500));
            ClickMouse2(Mouse_Left);
            Result := True;
            If Result Then
            Begin
              Writeln('Teleporting');
              Exit;
            End Else
              Writeln('Not teleporting');
          End;
        End;

      ColorToleranceSpeed(CTS);
      End;
     End;
    End;

    Not sure why this gives me

    New window: 1248828
    Compiled successfully in 842 ms.
    SRL Compiled in 0 msec
    Found HomeTele
    Clicked Home Teleprot
    Found LodeStone Screen!
    Teleporting
    Error: Out Of Range at line 344
    The following DTMs were not freed: [SRL - Lamp bitmap, 1]
    The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  2. #2
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    What is at line 344? Try setting the lengths of Loc and Points at the beginning of the function:

    Simba Code:
    // ...
    If(Not(LoggedIn))Then Exit;
    GameTab(tab_magic);
    Result := GameTab(tab_magic);
    If Result Then
     Begin
      SetLength(Loc, 3);
      SetLength(Points, 3);
      FindHomeTeleport(x,y);
      // ...

  3. #3
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    If Capitalize(Where) = Loc[I] Then


    That is the line giving me the error.
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  4. #4
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Hmm...

    Try to do this:
    Simba Code:
    Function Teleport(var Where: String): Boolean;

  5. #5
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    How would I call it then? I have
    Simba Code:
    Teleport('Catherby');
    but it gives me Variable expected.
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  6. #6
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Erm 0 based arrays and your for loop has 4, it should be 0 to 2

    0, 1, 2, 3
    and
    0, 1, 2

    Edit :
    Simba Code:
    For i := 0 To 3 Do
    Should be
    Simba Code:
    For i := 0 To 2 Do
    Last edited by Kasi; 07-09-2012 at 12:19 AM.

  7. #7
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by pur3b100d View Post
    Erm 0 based arrays and your for loop has 4, it should be 0 to 2

    0, 1, 2, 3
    and
    0, 1, 2

    Edit :
    Simba Code:
    For i := 0 To 3 Do
    Should be
    Simba Code:
    For i := 0 To 2 Do
    This. Because it doesn't have the 4th one, hence out of range.

  8. #8
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    Quote Originally Posted by pur3b100d View Post
    Erm 0 based arrays and your for loop has 4, it should be 0 to 2

    0, 1, 2, 3
    and
    0, 1, 2

    Edit :
    Simba Code:
    For i := 0 To 3 Do
    Should be
    Simba Code:
    For i := 0 To 2 Do
    I'll fix that and thank you. I don't know how I over looked that.

    **Edit I believe that fixed the error. Repp++
    Last edited by Element17; 07-09-2012 at 12:23 AM.
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  9. #9
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Quote Originally Posted by 14578 View Post
    I'll fix that and thank you. I don't know how I over looked that.
    The best way to overcome stuff like this is using (High(array) - 1), that way you dont have to search through the whole script changing integers

  10. #10
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    Thanks for the tip man, and again thanks for the help
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

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
  •