LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop second inner while loop inside the Event structure

Rshah31_0-1770642431934.png

Hello, 

I am new to labview. i have two While loop. I have "OK button" event. When I press Button event will trigger. and while loop inside the event loop starts. Now, My problem is if I want to stop this inside while loop and go out off the event. I, actully, can not. So my question is how can I exit second inner loop. PLease give me your valuable suggestion. 

0 Kudos
Message 1 of 8
(158 Views)

First and foremost, logic inside the event structure must be minimal and never any loops.

You may need to adopt a Queued State Machine or Queued Message Handler to do the actual work and the event handler loop must be light to respond quickly.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution
0 Kudos
Message 2 of 8
(151 Views)

Structures execute when all inputs are ready and exit when all are done. Your button is outside the structure and thus only read once before the loop. What are you trying to do?

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 8
(115 Views)

@Rshah31 wrote:

I am new to labview. i have two While loop. I have "OK button" event. When I press Button event will trigger. and while loop inside the event loop starts. Now, My problem is if I want to stop this inside while loop and go out off the event. I, actully, can not. So my question is how can I exit second inner loop. PLease give me your valuable suggestion. 


If you are new to LabVIEW, you should not even use an event structure. That comes later. First learn about the magic of dataflow. Using execution highlighting should clear things up.

 

That said, if the inner loop should stop when the stop button is pressed, it can be done, but it would be clumsy and ugly. Don't do it!

 

  • place the stop terminal inside the innermost loop
  • Configure the event to not lock the front panel until the event completes.

 

In a more sane architecture, events should never (never ever!) contain inner interactive code. Having a greedy while loop that hammers the same indicator with the same value millions of times per second burning an entire CPU core is pointless. You really only need to write to a terminal if the new value differs.

 

On a side note, if you want help, you need to attach your VI because pictures are insufficient to tell the whole story (what are the mechanical actions of the booleans? What is in the other event cases and case structure cases? What is outdside the visible area? How is the VI configured?)

 

Why wire to the newval event data node if the terminal is right there?

 

Start with telling us the purpose of the program. Tell us what you are trying to do, not how you are trying to do it. Most likely it can be done with half the code. Cleaner and better. Fitting on a postage stamp!

0 Kudos
Message 4 of 8
(86 Views)

Here is some simple code that toggles an LED whenever the OK button is pressed. Study this first until you understand all parts.

 

altenbach_0-1770659289189.png

 

0 Kudos
Message 5 of 8
(84 Views)

@santo_13 wrote:

First and foremost, logic inside the event structure must be minimal and never any loops.


Fast loops are OK.

paul_a_cardinale_0-1770659466751.png

 

0 Kudos
Message 6 of 8
(82 Views)

@paul_a_cardinale wrote:

@santo_13 wrote:

First and foremost, logic inside the event structure must be minimal and never any loops.


Fast loops are OK.

paul_a_cardinale_0-1770659466751.png

 


 

Yes, the key words are never use "interactive code" inside event cases. (...of course there are exceptions, requiring a skilled programmer to avoid any landmines... 😄 )

0 Kudos
Message 7 of 8
(80 Views)

@altenbach wrote:

@paul_a_cardinale wrote:

@santo_13 wrote:

First and foremost, logic inside the event structure must be minimal and never any loops.


Fast loops are OK.

paul_a_cardinale_0-1770659466751.png

 


 

Yes, the key words are never use "interactive code" inside event cases. (...of course there are exceptions, requiring a skilled programmer to avoid any landmines... 😄 )


Thank you for clarifying my intent

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution
0 Kudos
Message 8 of 8
(61 Views)