LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with one loop in another one

That is great, just what I want.

Now It seems I can remove "STOP" button for inner loop and event case for this "STOP", just leave STOP 2 to control inner and outer loops. It seems work good. But you may see some potential problems since I remember that you ever said this STOP even is very important.

Please check my program. It looks you solve my problem. Many many thanks

0 Kudos
Message 11 of 17
(778 Views)
I thought about doing it like that, too. 

But when I looked at it closely, I realized that the outerloop would only execute once. Robot surprised  So, then we are back to my earlier "you don't need an outerloop" argument.  Perhaps we need to step back a bit.  What sort of things are you putting in the outer loop? 
0 Kudos
Message 12 of 17
(775 Views)

Yes. I have a lot staff in outer loop.

Let me make it sinple first.

I have stack sequence structure. When program goes through other sequences and coe back to sequence "0". I want the wile loop is running so that the radom number is changing.

Now we stop this while loop with event control "STOP 2". How do we make while loop autumatically runs again?

 

0 Kudos
Message 13 of 17
(765 Views)
How often do you intend for the random number to be updated?
0 Kudos
Message 14 of 17
(760 Views)
Once I turn back to this sequence, I wish it keep updating all the time unless I use event stop loop.
0 Kudos
Message 15 of 17
(754 Views)
Hrm.  How about we move the random number and indicator inside the inner while loop.  Then we can wire a zero the timeout (little blue hourglass in the top left corner).  Normally, a case structure will wait forever for user input.  If we wire the timeout, it will execture the timeout case every X ms.  With a zero, it will execute as fast as the processor is able. We don't have anything in the timeout case, but it will execute the rest of the while loop before starting over.  So now the random updates all the time until we hit "stop 2".  Since we just moved all the outer while loop contents into the inner while loop, we might as well just get rid of that one.

How do we get the stacked sequence to start over?  With a while loop.  This time the while loop goes around the entire structure.  How do we stop this outer outer loop?  That depends on when you want it stopped.  If you want it stopped in the "0" frame, we need to implement the two stop button solution I showed earlier.  If you want it stopped in some later frame, put the stop button there.  There are a couple clever tricks you can use to either prevent it from being pressed in the "0" frame or allow the outer outer loop to be stopped from any frame.

As a general rule, I try to stay away from stacked sequences.  I like seeing all my code at once and the wires do a good job of ensuring that things happen in the right order.
0 Kudos
Message 16 of 17
(748 Views)

Sorry. Since the program is too big and complicated to post here. I use Radom number just to present other staff in out loop, they need to run all the time. They all can not be place inside inner loop.

My difficulty here is those event structure loop. They are just for making an array with selected scursor X position (unknow size array). Without this event structure loop, my program works good. Or placing this loop outside of outer loop, it wrks good too. However, I really want them inside outer loop. 

As I said the program is too big, we add more and more. Now we have problem to add more.

I simplify my problem just for easy communication.

I am thinking if we can add scursor position data into array without event structure. We may make things easy.  

 

 

0 Kudos
Message 17 of 17
(742 Views)