LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop while loop in Event case?

Hi, I was encountering a similar problem as ceties and the timeout solution seems to work well.  However, I still don't quite understand why the original example "StopWhileLoop.vi" isn't an equally good solution.  It seems to have the exact same functionality as the "StopWhileLoopMOD.vi".
 
I was using the labview example "new event handler.vi", which seems to contradict the sentiment of not blocking an event structure with a loop.  Or perhaps that rule doesn't apply when the loop is in a subvi?
 
If anyone can help clear up my confusion on this (or point me toward some relevant text) I'd greatly appreciate it.
 
Ken
0 Kudos
Message 11 of 19
(3,546 Views)


@halvorka wrote:
...  However, I still don't quite understand why the original example "StopWhileLoop.vi" isn't an equally good solution.  It seems to have the exact same functionality as the "StopWhileLoopMOD.vi".

They only act the same under certain use patterns. You will see a difference if you do the following (for example):

  1. Run VI
  2. press start
  3. press quit

You will notice that the original program cannot be stopped unless we stop the inner loop first. Running the inner loop locks the event structure and prevents anything else in the same loop from triggering. It is a very bad idea to trap the code in an inner loop inside an event structure. Makes sense? 🙂

Casual users hate programs where buttons becomee unresponsive and the manual needs to be complicated and unintuitive. ("You must click X,Y,Z in the following order", "don't click on Y after clicking on X", "If you accidentally click Z, you must ..." etc.... well you get the picture).

What good is dataflow if it cannot flow! 😄

Message Edited by altenbach on 06-04-2007 08:36 AM

Message Edited by altenbach on 06-04-2007 08:37 AM

0 Kudos
Message 12 of 19
(3,541 Views)

Thank you...That makes a lot of sense.

Ken

0 Kudos
Message 13 of 19
(3,509 Views)

Using your StopWhileLoopMOD[1].vi, I am trying to put a state machine inside the event structure. 

 

Here is my application:  on the front panel, the user can select any combination of 7 different tests.  I have created cases to perform each step of each test in the correct order, but if the user presses stop, the tests won't stop because some of the cases have a while loop inside the event structure (like you mentioned is a bad idea).  The user should be able to stop the test, reselect tests to perform, and re-start the tests. 

 

When the start button is pressed for the event structure, I need all the cases to run in the proper order, unless stop is pressed. 

 

In the past I have indexed an array and used that to run the state machine, but it won't stop immediately.  




metzler CLAD
0 Kudos
Message 14 of 19
(3,144 Views)

(You added to a thread that is over 3 years old with a new problem. Please start a new thread and refer to this thread in the description using a link. Since this is not your thread, you cannot mark a solution to your problem.)

 

In any case, You are missing the point. Interactive code does NOT belong inside event cases. You can easily use the outer while loop for anything and everything. Use the timeout case for looping states and manipulate the timeout value depending on state.

 

Why don't you start a fresh thread, link to here for background information, attach your code and we try to show you a better architecture. 😄

0 Kudos
Message 15 of 19
(3,134 Views)

to generate a vector of 100 integers (0-9) after randum logic - incidental!
numbers convert to string against snimanje file and after 5 wrong - every 6th to start a new line.
numbers in the string to be divided with TAB!
Is super only count from 1 to 10 I need to count from 0 to 9 how to fix it?

0 Kudos
Message 16 of 19
(2,560 Views)

First of all, this is now a six year old thread unrelated to your question. Please start a new thread. Also please use normal characters in the file name, your VI cannot be downloaded correctly using chrome on windows.

 

Did you use google translate to generate your question? It is nearly incomprehensible!

 

Anyway, try something like the attached (LabVIEW 9). See if it works for you.

0 Kudos
Message 17 of 19
(2,545 Views)

Thanks it is a good but if I want to move from 0 to 5
one still this if you can last
Thanks a lot

0 Kudos
Message 18 of 19
(2,510 Views)

@strunf wrote:

Thanks it is a good but if I want to move from 0 to 5


... then you change a single diagram constant on the block diagram. I am sure you can figure it out. 😄

0 Kudos
Message 19 of 19
(2,478 Views)