Results 1 to 7 of 7

Thread: Type Mismatch

  1. #1
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default Type Mismatch



    How do I fix this? Basically I want the Point R to be the middle of my ATPA[i][k] That way I can move to that point, check for uptext then click the rock if it is indeed there, but Im lost..

    Code
    Simba Code:
    Function FindRocks: Boolean;
      Var
        TPA : TPointArray;
        ATPA : T2DPointArray;
        I, X, Y, K : Integer;
        R:TPoint;

    begin
     ColorToleranceSpeed(2);
     SetColorSpeed2Modifiers(0.02, 0.19);
    if FindColorsSpiralTolerance(X, Y, TPA, 4224658, MMX1, MMY1, MMX2, MMY2, 13) then
      begin
      if (Length(TPA) >= 5) then
      begin
        ATPA := TPAtoATPAEx(TPA, 15, 15);
        SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
        for i := Low(ATPA) to High(ATPA) do
          for k := Low(ATPA[i]) to High(ATPA[i]) do
      begin
        if GetArrayLength(ATPA[i][k]) > 5 then
       begin
        R := MiddleTPA(ATPA[i][k]);

  2. #2
    Join Date
    Apr 2012
    Posts
    157
    Mentioned
    10 Post(s)
    Quoted
    57 Post(s)

    Default

    You would need to use a TPointArray, and grab the middle with Middle(TPA). And if I am not mistaken, your R variable, would have to also be an Array.

    Code:
    Atpa := TPAtoATPAEx(Tpa, width, height);
      for i := 0 to High(atpa) do
      begin
        if Length(atpa) > 5 then
        begin
          l := getarraylength(Result);
          SetArrayLength(Result, l+1);
          Result[l] := MiddleTpa(atpa[i]);
        end;
      end;
    Last edited by serajin; 03-31-2013 at 03:31 AM.

  3. #3
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    In the inner nested loop (the for k loop), you are going through TPoint types, not TPointArrays as in the outer for i loop.

    Thus, the MiddleTPA function call is taking in a TPoint type and therefore gives you the error of a type mismatch (is supposed to take a TPointArray type argument)

    Cheers,
    Le Jingle

  4. #4
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    In the inner nested loop (the for k loop), you are going through TPoint types, not TPointArrays as in the outer for i loop.

    Thus, the MiddleTPA function call is taking in a TPoint type and therefore gives you the error of a type mismatch (is supposed to take a TPointArray type argument)

    Cheers,
    Le Jingle
    Okay, how do I find the middle of that then? I understand what you are saying :P

  5. #5
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Quote Originally Posted by SRLKing View Post
    Okay, how do I find the middle of that then? I understand what you are saying :P
    Use one loop, the for i loop and exclude the for k loop!
    (Sometimes the solution is easier than you think ;])

  6. #6
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    Use one loop, the for i loop and exclude the for k loop!
    (Sometimes the solution is easier than you think ;])
    okay! Thanks :P

  7. #7
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    @Le Jingle will you TV me, I need some help, Im beating my head on the floor pm me.

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
  •