08-30-2010 01:59 PM
Since you're looking for an array (row) in a 2D array the basic Search in 1D array wont really cut it. However, LV is clever enough to compare array with a normal = command. So by looping through the 2D array you can compare the row with the 1D ones following the same logic (-1 for not found, stop search on found) with the following:
or like this (at 2nd thought i like this better)
/Y
08-30-2010 02:36 PM - edited 08-30-2010 02:44 PM
We're almost there.
For's solution can get rid of one boolean operation if the comparison is set to compare aggregates. Also the "select" needs to be done only once, and not with every iteration of the loop. (not sure if the compiler can recognize it as loop invariant code...probably not).
Yamaeda's solution above needs a FOR loop instead of a while loop, eliminating evaluation of the extra termination condition.
Here's what I would do:
08-30-2010 02:39 PM
To be fair, Yamaeda is using LV8.2. But, for those of us "living in the now", the For loop is the way to roll.
08-30-2010 02:43 PM
Ah, OK. I did not read the signature... 😉
08-31-2010 11:54 AM
Well I'm running 2010 at home for a while longer, didn't think about the aborting For.
/Y