From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop while loop after last element of array

Solved!
Go to solution

I want to stop a while loop after the last element of an array. I cant use the array size way because the size of the array can change within the program.  What should I do?

0 Kudos
Message 1 of 7
(5,345 Views)

Use a For Loop with autoindexing?

 

Does it have to be a While Loop?

Message 2 of 7
(5,342 Views)

Taki1999 mentioned 'For Loop' already. You can activate also the 'Conditional Terminal' of the For Loop, if you need to stop the loop because of any additional condition, like Boolean value, etc...

0 Kudos
Message 3 of 7
(5,326 Views)
And of course you can use array size to stop the loop. The for loop is the smart thing to use but a simple comparison between the array size and the iteration count can be used.
0 Kudos
Message 4 of 7
(5,308 Views)
Solution
Accepted by topic author fghfghgfhfhg

Why don't you use the empty array function like this...?

2015-07-30 18_02_48-G15-0440.vi Block Diagram on ABT.lvproj_My Computer rev. 36 _.png

0 Kudos
Message 5 of 7
(5,219 Views)

@Jimmy.chretien wrote:

Why don't you use the empty array function like this...?

2015-07-30 18_02_48-G15-0440.vi Block Diagram on ABT.lvproj_My Computer rev. 36 _.png


I'm not sure the OP meant to stop the loop when the array is empty.  I think they want to stop it after the least element was processed.  At any rate, generally use a for loop if you know the size of the array ahead of time, a while loop if you do not.

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 7
(5,207 Views)

Ok Thanks guys

0 Kudos
Message 7 of 7
(5,133 Views)