LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

need help terminating program

Hi, I'm just about satisfied with a rough draft of my program, but I've found now it will enter into an infinite loop.  This is what I want the program to do:

 

1. enter money

2. press a button for selection

3. calculate change

4. reflect calculated change at the input

5. terminate program

 

I've got 1-3 to work, but when I reflect the change at the original input this is where it enters a crazy loop.  Is there an easy way to terminate from a case structure?  When I tried doing this, as you can see in my code, it terminates the program but it doesn't calculate change at all.  I'd like it go in sequential order, then terminate.  Sorry if my code is messy too, it's rough draft so far.  I'm using verison 8.2

 

 

**edit: this version I've put the stop commands on each case structure that calculates change, and the program just terminates.  Without these added it enters the crazy loop.
Message Edited by JJJOndae on 05-17-2010 10:58 AM
0 Kudos
Message 1 of 4
(2,801 Views)
This application is crying out to be rewritten using a State Machine architecture.  It would be a piece of donut that way.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 2 of 4
(2,775 Views)

OMG.  (sorry for the chat abbreviation).  I have to agree with Jim.  The entire vi needs to be re-written from scratch.  A state machine is the way to go.  Using the Labview Stop function is bad practice.  If other parts of the code are still executing, like a loop in mid loop, they will come to a halt when the first Stop is executed.  My suggestion to JJJ is to study the state machine architecture (look for examples), then re-write the code using a state machine.  Post your re-write and ask for help.  I don't think anyone would want to try to fix your current vi.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 4
(2,762 Views)

Piece of donut? Not a fan of cake huh? Smiley Very Happy

 

A few pointers for the OP:
- Try to avoid the 'Stop' function, it doesnt do exactly what you think it does. It will literally halt your program, instead of stopping just the current loop. This is not generally a good idea, because usually after a loop there are some loose ends (punn intended) that should be cleaned up.

- You have too many local variables. This will cause race conditions in your code if you are not careful.

- As Jim said, you should think about re-writing the code using a state-machine architecture. This will help avoid your a lot of your boolean acrobatics Smiley Tongue Feel free to ask questions if you are unsure how to set up a state-machine.

 

Edit: tbob pretty much beat me to the punch on this one haha

Message Edited by Cory K on 05-17-2010 01:34 PM
Cory K
0 Kudos
Message 4 of 4
(2,760 Views)