LabVIEW Idea Exchange

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

add a while do loop

Status: Declined

Any idea that has received less than 2 kudos within 2 years after posting will be automatically declined.

The current while loop executes and then checks the termination condition.  This is known as a do while loop.  First you "do" then you "check".  Can you add a "while do" loop.  This would first check the termination condition and then either execute or not.  I know I can put a do while loop in a case structure and build the same functionality as a while do loop, but it would be much easier if I could just configure the while loop to check first then execute or execute and then check.

3 Comments
crossrulz
Knight of NI

Your other work around would be to put your "do" code inside of a case structure inside of the loop so that it does not execute on the first iteration of the loop.  Then you don't have duplicate logic for the stop condition.

 

Even still, I'm trying to remember the last time I actually wanted this.  Do you have a good example of where you would use this?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
AristosQueue (NI)
NI Employee (retired)

Jim12345678: Got any pictures of how you'd want such a loop to be drawn? You can't say "oh, just check the stop condition first" without providing some mechanism for making the iteration code dataflow dependent upon the stop condition code. That's going to look pretty much the same as a While Loop around a Case Structure. We could draw a bar down the middle of the While Loop and put a ? terminal on it, but that's really going to play havoc with tunnels that need to come out of the stop condition computation. In the end, I don't think you'll be able to draw any picture of a while-do loop that looks any different from a While Loop around a Case Structure.

Darren
Proven Zealot
Status changed to: Declined

Any idea that has received less than 2 kudos within 2 years after posting will be automatically declined.