04-22-2010 03:55 AM
Hello community,
I have a question about a DO WHILE loop. I use the While loop frequently, but now I'm in need of a DO WHILe loop. I want it to run once, then wait for a user input that decides whether to run it again or procede. I'm running a meassurement that ocassionally fails, so I want the opertunity to rerun it bevore I move on to the next step.
I'm sure there is a simple solution, I just don't see it.
Thank you in advance,
Florian
04-22-2010 04:06 AM
Based on your requirements, I suggest you to use a state machine. You will find plenty of information on this on this forum, the ni web page. You also have a template with your LV installation.
Felix
04-22-2010 04:17 AM
Hi Florian,
attached you´ll find two screenshots/VI snippets of examples, currently I don´t have access to a LV 7.1 installation, but these two are very simple to reprogram.
1. Acquire the data and thenWiat for the user input. On "Measure again?" you run the loop a second time, on Measurement ok, you leave the outer loop and give your data to wherever you need it.
2.
The smarter way, if you have to wait for a USER reaction, is to use a Event structure for acquiring and stopping the main loop.
Hope that helps.
Stefan K.
04-22-2010 04:42 AM
Florian,
The "while loop" that comes with LabVIEW actually is a "do while loop" since it will defenetly execute atleast once.
Or to say that the "while loop" are actually "do while loops" in LabVIEW.
What you need is some thing like a state machine or events like others mentioned
Guru