LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I feel as if I am using too many local variables

Solved!
Go to solution

Hey Guys,

 

I have attached the code below. I am interested in specifically the double case structure towards the right side of the screen. I am pretty familiar with using language similar to "i = i+1" so naturally I use a lot local variables. But I need to begin to simplify with labview, I know it is important use local variables/ property nodes only when necessary. I know I need shift registers, but I need some suggestions on how to simplify this code. Thanks for your help. 

0 Kudos
Message 1 of 3
(2,944 Views)
Solution
Accepted by topic author arosss

Sequence Structures usually scream that you need to look at using a State Machine.

 

Related, the waits are not necessary since you already have user interactions handled with popups and/or Event Structures.

 

The Timeout event should not be needed.  I think you can just replace it with a Reset button's value change event.  The logic for going over should be moved to the Hit value change event.

 

For the dealer, the logic should cover if they beat the player (either the player went over or the dealer already has a higher value) or the dealer went over.  That is the main advantage of being dealer in Black Jack.

 

But, yes, all of your local variables could easier be handled with Shift Registers, especially in a well designed state machine.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 3
(2,920 Views)

Thanks for being concise, will make the updates.

0 Kudos
Message 3 of 3
(2,913 Views)