Showing results for 
Search instead for 
Did you mean: 

End While Loop after False Case Structure is Executed

I have all of the program executing properly except for ending the program after we have executed the false case structure.  Can someone help me end the program after the false structure has been executed.  I want to continue executing the while loop if the AND function is true.

0 Kudos
Message 1 of 8

You already have it set up right.  The same condition that determines the case structure also determines whether the loop continues.  Just wire that to the loop condition (continue if true)

using LV2017SP1
0 Kudos
Message 2 of 8

When I connected the continue if true to the AND function it stopped the loop prior to executing the false case.

0 Kudos
Message 3 of 8

I would recommend adding a case structure with an enum. Have attached the code, check if it works.

0 Kudos
Message 4 of 8

I am away from my hardware and machine that has labview, but will give it a try when I get back to it next week! Thank you!

0 Kudos
Message 5 of 8

Don't create a DAQ task inside the loop every iteration, and certainly not if you fail to close the task.  Right now your endless creation of task is a memory leak that will eventually crash your computer.  Put the Create Task outside the while loop and a Clear task after the while loop.


Your True and  False cases are nearly identical other than the constant wired into the analog write.  No need to duplicate the code.  Pull it out of the case structure other than the constants.  And since it is "either" one constant or the other, get rid of the case structure and just use a Select statement.


Since your loop is set to continue when True, just wire the comparison to the Continue Terminal?  It will continue the loop when true and stop the loop when false.


One problem you might have is the use of the Dynamic Data Wire.  You really don't know what type of data is on that wire, boolean or numeric, and whether it is a scalar or an array.  Convert the blue wire to a real datatype as soon as possible.

Message 6 of 8

Is this how you think it should look? I still think this loop will stop before writing a 0 if the AND becomes false.  Right?


I still have to place a clear task as well.

0 Kudos
Message 7 of 8

Loops always complete internal code before exiting, so it should work fine, assuming the stop terminal understands that dynamic data.

using LV2017SP1
0 Kudos
Message 8 of 8