LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

How to determine if an array has reached the end

Solved!
Go to solution
Highlighted
I am using a recursive file list with a for loop. This at the end is an array, and I wish to lnow when the array of files has reached the last file if I am reading them one by one, without deleting them.
0 Kudos
Message 1 of 6
(1,437 Views)

Not sure exactly what you need, But you can always get the size of the array and compare with the current index to tell if you have reach the end of the array.

 

Post a screen shot of your code will help.

0 Kudos
Message 2 of 6
(1,426 Views)
Solution
Accepted by topic author Nando88
05-21-2016 07:29 AM

Maybe I'm not understanding, but if you wire it to a for loop and indexing is on, the loop will stop when the last element in indexed in, just don't wire the loop count.

0 Kudos
Message 3 of 6
(1,424 Views)

If you do wire the lop count, you'd still never exceed the array.  You'd just take a subset of the array if the count terminal was a smaller number.

0 Kudos
Message 4 of 6
(1,421 Views)

Simple answer: compare iteration index with array size.

 

For more detailed answer we need VI with algorithm (C) Bob

 

If you are using for loop, you know number of iterations you want to execute. If you want to abort on some condition (file has bad name), you know this condition.

Recursive usually means while loop: you add files to the list and process them one by one. You add to the end of array, process from beginning. You may need to keep counter in shift register and increment it every time you process file.

 

Check recursive file list.vi from the Advanced file functions, it might help

0 Kudos
Message 5 of 6
(1,415 Views)

Probably if we knew why you needed to do this, we could give you a much more complete answer.

 

For instance, if you just need to iterate over the array, autoindexing will cause the loop to exit after the last element of the array was worked on.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 6
(1,400 Views)