LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop doesn't stop until 2 more clicks

Solved!
Go to solution

I have to say I am really not familiar with LV at all, but Im learning.

So, why is that after I clicked stop bottom, I had to click my OK button twice, then my program stopped. Why it can't stop immediately?

Besides, if I want to some the dice result by array, which wire am I missing?

Thank you!

0 Kudos
Message 1 of 8
(2,714 Views)
Solution
Accepted by topic author RawtoLV

Hi RawtoLV,

 

You have a while loop within a while loop. When you run the other while loop stops when you pressed the stop button, the inner while loop still runs. Since your OK button is using Latch when released, what i noticed is that when you pressed that OK button, it quickly switched to from true to false which didn't stop that while loop operation (could be due to the wait). May I ask what are you actually doing with the sequence structure?

 

I would suggest using event structure instead (http://zone.ni.com/reference/en-XX/help/371361K-01/glang/event_structure/):

1.JPG

2.JPG

3.JPG

 

here some more info on event structure:

http://www.ni.com/white-paper/3331/en/

http://www.youtube.com/watch?v=8eO64fo3Pho

 

 

Warmest regards,

Lennard.C

Learning new things everyday...
0 Kudos
Message 2 of 8
(2,666 Views)

Oh,I put another while loop outside just to make sure the program keeps running.

So, is there any way to abort my program without clicking the 'abort' button?

The structure is for showing the same results as the dice rolled by the array.

0 Kudos
Message 3 of 8
(2,661 Views)

Hi RawtoLV,

 

Sorry. I was in the middle of modifying my comments till you replied. Anyways, you can use Event structure. As you have seen in my precious post, event structure is like case structure but this events (just like how we call cases in case structure) only executes when an event trigger is triggered. For my example, the code in the "OK Button" event only executes when you pressed the OK button (Value change means that when the OK Button value changes e.g. when you pressed the button, runs that code) meaning it runs once for this case. Since it runs once, the value from the dice still holds till you pressed the OK button again.   

 

Under the "OK button" event, I have used "number to boolean array" function to convert the number to boolean. 

 

11.JPG

 

Please note that you need to create an event for stop so that when you pressed stop, the code will abort.With the screenshots I have shown, you can stop the program without the need to pressing the OK button.  

 

I have added some reference links for you to learn how to create a event structure. 

 

Hope that meets your needs

 

Warmest regards,

Lennard.C

Learning new things everyday...
0 Kudos
Message 4 of 8
(2,653 Views)

Wow! Thanks really helpful! I just did it.

There is only one small problem now, that the sequence structure was for showing the same result as the dice rolled. I mean, if dice rolls 6, there should be 6 light on for that array. I dont know how to connect the result I got from the dice into that structure. Can you help me with that?

Thank you so much!

 

Sincerely,

ILoveThisForum

0 Kudos
Message 5 of 8
(2,641 Views)

Hi RawtoLV,

 

Have you tried adding that case structure from your precious code to this modified code like below?:
12.JPG

 

You'll need to convert that double floating precision data type to I32 using "To Long Integer" function.  

 

Let me know how it goes.

 

Warmest regards, 
Lennard.C

Learning new things everyday...
0 Kudos
Message 6 of 8
(2,635 Views)

I just saw that! Its all done that!

Can't thank you for more!

I really really appreciate your kindness help at midnight!

 

Best Regards,

Forgot My ID

0 Kudos
Message 7 of 8
(2,631 Views)

Hi RawtoLV,

 

You're welcome. Just create a new thread if you have any more questions. 

 

Warmest regards,

Lennard.C

Learning new things everyday...
0 Kudos
Message 8 of 8
(2,626 Views)