Results 1 to 9 of 9

Thread: Counting ATPA entries

  1. #1
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    1,220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Question Counting ATPA entries

    Hey,

    i want to count how many entries are in my ATPA, is this possible and how would i go about doing this?

    thanks for any help

  2. #2
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Writeln(High(ATPA));

  3. #3
    Join Date
    Aug 2009
    Location
    Inside the Matrix...yes it has me, and it has you too.
    Posts
    1,896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    High(x); works for ATPAs. It returns an integer for the highest part of the array.

    SCAR Code:
    Var
      ATPA: T2DPointArray;
      TPA, TPA2: TPointArray;
      TP1, TP2, TP3, TP4: TPoint;
      I: Integer;

    Begin
      TPA := [TP1, TP2];
      TPA2 := [TP3, TP4];
      ATPA := [TPA, TPA2];
      I := High(ATPA) + 1;
      Writeln(I);
    End.

    This returns as '2' in the debug box, the + 1 is there because it starts at 0.

    E: 'd. Silly detailed responses
    NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN

  4. #4
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    1,220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    Writeln(High(ATPA));
    thanks for that

    Quote Originally Posted by bionicle1800 View Post
    High(x); works for ATPAs. It returns an integer for the highest part of the array.

    SCAR Code:
    Var
      ATPA: T2DPointArray;
      TPA, TPA2: TPointArray;
      TP1, TP2, TP3, TP4: TPoint;
      I: Integer;

    Begin
      TPA := [TP1, TP2];
      TPA2 := [TP3, TP4];
      ATPA := [TPA, TPA2];
      I := High(ATPA) + 1;
      Writeln(I);
    End.

    This returns as '2' in the debug box, the + 1 is there because it starts at 0.

    E: 'd. Silly detailed responses
    cheers for the detailed one, its better to give detailed answers it better understood then :P

  5. #5
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    The actual amount is WriteLn(Length(ATPA))

    High is just the largest index.

  6. #6
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Isn't that the same thing?

  7. #7
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    Isn't that the same thing?
    No they can be quite different.

    SCAR Code:
    var
      S: array [5..10] of string;
      I: Integer;


    begin
      S[5] := 'see';
      S[6] := 'what';
      S[7] := 'I';
      S[8] := 'mean';
      S[9] := '=P';
      S[10] := '?';
      WriteLn(IntToStr(Length(S)) + ' values');
      WriteLn(IntToStr(High(S)) + ' high');
      WriteLn(IntToStr(Low(S)) + ' low');
      for I := Low(S) to High(S) do
      begin
        WriteLn('Index: ' + IntToStr(I));
        WriteLn('Value ' + S[I]);
      end;
    end.

    Code:
    Successfully compiled (80 ms)
    6 values
    10 high
    5 low
    Index: 5
    Value see
    Index: 6
    Value what
    Index: 7
    Value I
    Index: 8
    Value mean
    Index: 9
    Value =P
    Index: 10
    Value ?
    Successfully executed

  8. #8
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Well in most cases it'd start at 0.

  9. #9
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    Well in most cases it'd start at 0.
    If you start at 0 then he would need to add one. It's simpler/more accurate to use Length.

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
  •