NEXT ARRAY INDEX This command will move the internal array index to the next logical item.
Syntax
    NEXT ARRAY INDEX Array Name(0)
Parameters
    Array Name(0
Integer The name of the array followed by a pair of brackets ( ). You can also insert a value of zero, i.e. arrayname(0)
Returns
This command does not return a value.
Description
When the index reaches the end of the array, the ARRAY INDEX VALID() command will return a zero.
Example Code
    dim a() as integer

    empty array a()

    print "Add 5 items to the list"

    for i=1 to 5

       n = rnd(1000)

       print "  Adding "; n; " to the list"

       array insert at bottom a()

       a() = n

    next i

    print

    PrintList()

    print

    print "Run through the list forwards"

    array index to top a()

    while array index valid( a() )

       print a()

       next array index a()

    endwhile

    print

    print "Run through the list backwards"

    array index to bottom a()

    while array index valid( a() )

       print a()

       previous array index a()

    endwhile

    print

    print "Step forward to the third item and delete it"

    array index to top a()

    next array index a()

    next array index a()

    array delete element a()

    PrintList()

    print

    print "Now insert 3 new random numbers at the top of the list"

    for i=1 to 3

       n = rnd(1000)

       print "  Adding "; n; " to the list"

       array insert at top a()

       a() = n

    next i

    print

    PrintList()

    print

    print "Deleting every item under 500"

    array index to top a()

    while array index valid( a() )

       if a() < 500

          array delete element a()

       else

          next array index a()

       endif

    endwhile

    PrintList()

    wait key

    end

    function PrintList()

       if array count( a() ) >= 0

          print "The list has "; array count( a() )+1; " items"

          for i=0 to array count( a() )

             print "  Item "; i; " = "; a(i)

          next i

       else

          print "The list is empty"

       endif

    endfunction
See also
CORE Commands Menu Index