LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing values from case statements

Alright, I am programming an application and have run into a very frustrating problem. Basically its this: I have button on the front panel that when pressed, generates an array of strings and displays it. I have a second button programmed with the intention of allowing the user to save the data when it is pressed. Both of the buttons were originally OK buttons, so basically they're true when pressed and immediately revert to false when they're read. The problem arises from the fact that all of the buttons in my program are tied to case statements in an infinite loop. So basically my question is this: How do I get the array of strings out of the first case statement without it being overwritten mere fractions of a second later by the f
alse case for the same statement. I keep running into this problem over and over again where labview insists that all cases produce a value even when I only -want- one of the cases to produce a value and the other case to do nothing.
0 Kudos
Message 1 of 5
(3,234 Views)
Hello.
It sounds like what you need is a shift register, used to pass data from one iteration of a loop to the next. Instead of writing a very long paragraph describing this, I think it is best if you look at the attached image (I put in in image format since I do not know what version of LV you are using). Notice how in the false case of the first case structure, the array data is simply "wired through" so that it is not changed if the button is not pressed. I will also attach the VI in LV version 7.0 in case you have that version or later.
Download All
0 Kudos
Message 2 of 5
(3,234 Views)
While true that a shift register would allow me to pass data in that way, due to the massive size of my VI the shift registers would quickly become -very- cumbersome. Therefore it would be best if there was a way to pass a value without having to use shift registers. Isn't there a way for a case structure to pass a value or not pass a value without the use of a shift register?
0 Kudos
Message 3 of 5
(3,234 Views)
How about right clicking on the output terminal of your case structure and select use default if left unwired?

Robert
0 Kudos
Message 4 of 5
(3,234 Views)
You could update the value by writing to a local variable inside just one of the cases but could create problems other than a messy diagram. Locals create a copy of the data, break data flow, and other nasty things so they should be avoided when possible. You do not need a separate shift register for each value you might need to pass - bundle everything together and you can use a single shift register. A general rule of thumb is that a VI's diagram should fit on a single screen so if your's is "massive", you might want to check out some of the different architectures that allow for smaller diagrams that are easier to modify and maintain.
0 Kudos
Message 5 of 5
(3,234 Views)