Results 1 to 6 of 6

Thread: A little TPointArray function...

  1. #1
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default A little TPointArray function...

    While designing a fishing spot locating function, I am accross this idea...
    It works similar to AMax and Max, but instead of returning the length, it is returning the entire TPA with the biggest length... Might be helpfull to some... Using this in my fisher...
    I haven't tested it yet, but it should work...
    SCAR Code:
    {*******************************************************************************
    function ReturnHighestTPArray(TPAs : T2DPointArray): TPointArray;
    By: Pure1993
    Description: Returns the TPA with the highest length.
    *******************************************************************************}

    function ReturnHighestTPArray(TPAs : T2DPointArray): TPointArray;
    var
      carry, i : integer;
    begin
      carry := Max( length(TPAs[0]), length(TPAs[1]));
      if (High(TPAs) > 1) then
      begin
        for i := 2 to high(TPAs) do
        begin
          carry := Max(carry, length(TPAs[i]));
        end;
      end;
      for i := 0 to high(TPAs) do
      begin
        if carry = Length(TPAs[i]) then
          Result := TPAs[i];
      end;
    end;
    I know the name is "clumsy"... I just couldn't think of a better one...

    Didn't know where to put this, so I just followed RM's example and posted this in the suggestion part...

    PS. Sorry if something like this already exists... but I didn't find anything like this while searching for it...
    There is nothing right in my left brain and there is nothing left in my right brain.

  2. #2
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    InIntArrayEx(Array: TIntegerArray; var where: integer; number: integer): boolean;
    Array is the array of integers you are inspecting
    where is a variable. It tells wheter the number is found in Array[0], [1], [2] and so on.
    number is the number you are looking for.

    Try this, Highest=true returns the longest tpa, false returns the shortest tpa
    i didn't try if it works ^^ you have a good idea there anyways!

    EDIT: Added SetLength to TIA. Now it works I tried it, works 100%.
    SCAR Code:
    function TPALengths(ATPA : T2DPointArray; Highest: boolean): TPointArray;
    var
      TIA: TIntegerArray;
      i, w: integer;
    begin
     SetLength(TIA, Length(ATPA));
     for i:= 0 to High(ATPA) do
      TIA[i]:= Length(ATPA[i]);
     if Highest then
      InIntArrayEx(TIA, w, AMax(TIA))
     else
      InIntArrayEx(TIA, w, AMin(TIA));
     result := ATPA[w]
    end;
    Last edited by marpis; 04-27-2009 at 03:29 AM.

  3. #3
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    SortATPASize, anyone?
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  4. #4
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    oh, wasn't aware of that one... go ahead and close/delete this...
    There is nothing right in my left brain and there is nothing left in my right brain.

  5. #5
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Devs - Pure
    4 - 0
    ~Hermen

  6. #6
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Closed, thanks for your attempt!

    <3
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

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
  •