05-07-2020 09:41 AM
Hello, I have a program. I want to add a pause button in my program. I have searched how to make it, but I'm still confused to implement it in my program. I hope someone can give clues, Thanks.
Solved! Go to Solution.
05-07-2020 10:12 AM
05-07-2020 10:21 AM
when I click the pause button, the program stops and when I click again the pause button, the program runs again.
05-07-2020 01:21 PM
@michaelkeane24 wrote:
when I click the pause button, the program stops and when I click again the pause button, the program runs again.
The program should always run. "Pausing" is just one possible state (where it at least monitors the pause button for any changes).
05-07-2020 01:26 PM
I would start over and redesign the code as a simple state machine. You don't need any local variables!
Here is a translation of the game (using google translate of the front panel text):
PROCEDURES FOR PLAYING SELECTION BALL GAME
1. Before the game starts, the player must choose the desired game speed.
There are three options to choose from, namely Slow (4 seconds per turn), Medium (3 seconds per
turn), and Fast (2 seconds per turn).
2. The player must choose the red ball when the player is playing. Player
will get 1 correct ball.
3. If a player chooses the wrong ball, the player will get 1 ball
is wrong.
4. The game will end if it meets one of the following conditions:
a. The correct ball reaches 30
b. The wrong ball reaches 15.
c. The player clicks on the Stop button.
5. After the game ends, the player will see a dialog that displays
whether the player wins or loses, the total score, the correct total ball, and the total ball
wrong.
05-07-2020 03:07 PM - edited 05-07-2020 04:53 PM
Some comments to your code:
It can be done with <5% of the code (Your VI is 408kB, mine is 19kB!)! Attached is a quick draft that can give you some ideas. Let me know if anything is not clear. It would be easy to add the disable/enable feature, but I don't think it is needed.
05-07-2020 09:35 PM
Thank you so much, Sir.
05-07-2020 09:45 PM
I want to ask, I want to use State Machine Architecture to make this program later, is that possible to do that? I'm still studying State Machine Architecture and Cluster Function, thank you Sir.
05-08-2020 12:17 AM - edited 05-08-2020 12:18 AM
It already is a (very primitive) state machine with two states: paused or not.
05-08-2020 02:17 AM