02-06-2014 12:18 AM
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?
Solved! Go to Solution.
02-06-2014 12:32 AM - edited 02-06-2014 12:48 AM
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/):
here some more info on event structure:
02-06-2014 12:38 AM
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.
02-06-2014 12:48 AM - edited 02-06-2014 12:57 AM
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.
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
02-06-2014 01:10 AM
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!
02-06-2014 01:16 AM
Have you tried adding that case structure from your precious code to this modified code like below?:
You'll need to convert that double floating precision data type to I32 using "To Long Integer" function.
Let me know how it goes.
02-06-2014 01:16 AM
I just saw that! Its all done that!
Can't thank you for more!
I really really appreciate your kindness help at midnight!
Forgot My ID
02-06-2014 01:21 AM
You're welcome. Just create a new thread if you have any more questions.