LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop while loop in event loop

Dear All,

A newie in labview has a question. I am using LV 7.1.
I tried to stop a while loop by pressing on a "STOP" button. But the VI does not response.

Attached is a simplified code. It is modified from an example downloaded from this forum. It captures the main essential of my problem - I cannot stop the "counting" while-loop using the "two-loop" method if they are inside an event. If i remove the event, this code works fine.

To start, press the "start" button.
Then wait for a while and try to press the "Stop" button. But the VI will not response.

Anyone has a good solution for this?

Thank you.

wee
0 Kudos
Message 1 of 6
(3,663 Views)
Dear owlowl,
your piece of code here seems to be quite far from NI recommandations. You should read the online help. Just select the "Show context help", and select the event structure, then click the "Click here for more help".
You will find two interestings subjects as "Caveats and Recommandations :
- Avoid using an Event structure outside a loop.
- Avoid placing two Event structures in one loop.

Does that help ? 🙂
Keep wiring...
Chilly Charly    (aka CC)
Message 2 of 6
(3,663 Views)
Hi chilly (getting cold...... :P),

Thanks for your reply. My method was trying to mirror some C sequences into labview. I was letting some background processes to run while waiting for user input to start the process ("event loop") which has a while-loop acquisition process ("while loop in an event"). Anyway i have solved it by changing my flow.

I had some difficulties in getting the "Show context help". My labview was not responsing to my request. Think it could be some installation problems.

Thank you again.

owlowl

PS - Actually i found some labview features not as good as labwindows. For me, the latter is somewhat easier to understand and use.
0 Kudos
Message 3 of 6
(3,663 Views)
Hi owlowl !
Programming in LabVIEW is often confusing at the beginning. I think that Mirroring C techniques is not a good approach of LV. Of course, basically, there are the same functions running here and there, but there are a lot of specificities in LV that make the language powerfull and attractive. As you will discover, the LV community live with passion...
To start with, you should have a look at the FAQ, on this forum, and also on http://forums.lavausergroup.org/
And of course, you also need to be able to access the online labVIEW help, which is EXCELLENT.
To come back to your problem, avoid using nested event structure, and always use a while loop around an event structure. That will solve most of your difficulties.
I'll try to
post some example later for you.
Courage, keep wiring ! 🙂
Chilly Charly    (aka CC)
Message 4 of 6
(3,663 Views)
Hi owlowl,

Actually you�re not that far from reaching the goal in your first attempt. You�re just missing one small detail to make your VI behave as expected.

The �detail� that I�m talking about, is called �Lock front panel until the event case for this event completes�, and you find it when you edit the �OK Button� event (see the attached image). When DISABLING this feature, your code will be able to handle nested event structures.

�So you were pretty close in the first place!

Best regards,
Philip C.
Applications Engineer
National Instruments
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
Message 5 of 6
(3,663 Views)
Hi Philip,

You are right on. Thank you.

owlowl
0 Kudos
Message 6 of 6
(3,663 Views)