Jump to content

Need to Display every other result in an Array


kjbopp
 Share

Recommended Posts

I need to display every other result in an array, i.e. my array consists of:

[1][0] = "xxx"

[1][1] = "yyy"

[1][2] = "xxx"

[1][3] = "yyy"

...and I just want either all the "x's" or all the "y's" or every other value

This is the snippet that displays the array

For $i = 1 To $NumofCols
   $s = $s & $array[1][$i-1] & @CRLF
Next

MsgBox(4096, "Array", $s)

Not sure how to manipulate the second element of the array. Thanks in advance for any advice.

Link to comment
Share on other sites

You can do that like this:

$iStart = 0 ; Read even
For $i = $iStart To UBound(, 2) - 1 Step 2
    $s &= $array[1][$i] & @CRLF
Next
$s &= @CRLF

$iStart = 1 ; Read 0dd
For $i = $iStart To UBound(, 2) - 1 Step 2
    $s &= $array[1][$i] & @CRLF
Next
$s &= @CRLF

MsgBox(4096, "Array", $s)

Merry Christmas!

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...