Results 1 to 6 of 6

Thread: Get total number of indexes in array

  1. #1
    Join Date
    Feb 2013
    Posts
    89
    Mentioned
    1 Post(s)
    Quoted
    12 Post(s)

    Default Get total number of indexes in array

    how would i get the number of indexes in an array?

    for example

    Simba Code:
    for i := 0 to ArrayCount do

  2. #2
    Join Date
    Nov 2012
    Posts
    2,351
    Mentioned
    55 Post(s)
    Quoted
    603 Post(s)

    Default

    Simba Code:
    Integer := High(ArrayName);

    ? At least I think thats what you are after

    Simba Code:
    for i := 0 to High(ArrayName) do
      ArrayName[i] := i;
    Last edited by DannyRS; 03-14-2013 at 08:41 PM.


    Programming is like trying keep a wall of shifting sand up, you fix one thing but somewhere else starts crumbling

  3. #3
    Join Date
    Feb 2013
    Posts
    465
    Mentioned
    6 Post(s)
    Quoted
    221 Post(s)

    Default

    You could also use Length() ie.
    Code:
    for i := 0 to length(ArrayName)-1 do
      ArrayName[i] := i
    Last edited by wthomas; 03-14-2013 at 09:02 PM. Reason: Fixed code

  4. #4
    Join Date
    Feb 2013
    Posts
    89
    Mentioned
    1 Post(s)
    Quoted
    12 Post(s)

    Default

    Yes perfect!! thank you both!

  5. #5
    Join Date
    Nov 2012
    Posts
    2,351
    Mentioned
    55 Post(s)
    Quoted
    603 Post(s)

    Default

    Quote Originally Posted by wthomas View Post
    You could also use Length() ie.
    Code:
    for i := 0 to length(ArrayName) do
      ArrayName[i] := i
    Length is High() + 1, so that would throw out of range runtime error,

    Simba Code:
    for i := 0 to (length(ArrayName)-1) do
      ArrayName[i] := i


    Programming is like trying keep a wall of shifting sand up, you fix one thing but somewhere else starts crumbling

  6. #6
    Join Date
    Feb 2013
    Posts
    465
    Mentioned
    6 Post(s)
    Quoted
    221 Post(s)

    Default

    Quote Originally Posted by DannyRS View Post
    Length is High() + 1, so that would throw out of range runtime error,

    Simba Code:
    for i := 0 to (length(ArrayName)-1) do
      ArrayName[i] := i
    Derp. my bad

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •