LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

call case statement inside case statement

Solved!
Go to solution

I am writing a program which requires me to execute a case statement inside another case statement. Although this sounds like a simple thing, I need to be able to call the case statement using a sequence structure, where s1 sends a true value to the case, s2 a false. I then need to save the results of this case statement to a text file. Attatched is a simplified version of what I am trying to do. Also please note that do to the way my program executes I cannot call the case statement without using a sequence structure, so nesting the two case statements is not feasible. Hopefully someone out there can help me as I have been stuck trying to work this out for a while.

 

Thanks

 

0 Kudos
Message 1 of 10
(3,913 Views)
Sorry here is the attatchment.
0 Kudos
Message 2 of 10
(3,912 Views)

Look into using a State Machine for this. It will work just great. I will also save you from using local variables which have there place but are usually abused. I was going to write you a quick example but have to head home. I'm not sure of your logic of when to 'Save' and when to 'Calculate' ? I'll try to write and example if I have time when I get home. There are plenty of example on this site if you search. Once you learn this construct you will really be on your way..

 

Hope this helps.

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 3 of 10
(3,900 Views)
I think a state machine or a event driven architect can work for you.
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 4 of 10
(3,894 Views)

I dont think I can use a state machine to solve this problem. The program I am working on performs a detailed calculation on one data set when the user hits the calculate button. However when I have several sets of data I want to be able to automatically perform a calculation on each of these data sets and then append the results to a text file. Hence the two seperate case statements. If someone could provide an example that would be really helpful.

 

Thanks again.

0 Kudos
Message 5 of 10
(3,880 Views)

LVStudent wrote:

 The program I am working on performs a detailed calculation on one data set when the user hits the calculate button.


Event structure with a producer/consumer architecture using queue's or other methods.

"However when I have several sets of data I want to be able to automatically perform a calculation on each of these data sets and then append the results to a text file."

Seperate data acqusition from processing and filing.

These are pretty advanced concepts..what is your time line to finish this?

 

There are plenty of good people here to help!

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 6 of 10
(3,873 Views)
I am working on a program for my thesis. So the sooner I get it done the better, then I can have something to write up.
0 Kudos
Message 7 of 10
(3,867 Views)
Well, for starters the stacked sequence structure is normally not a good structure to go with also you may have some race conditions with your local variables.
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 8 of 10
(3,850 Views)

LVStudent wrote:
I am working on a program for my thesis. So the sooner [you] get it done [for me] the better, then I can have something to write up.
 

 

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

0 Kudos
Message 9 of 10
(3,828 Views)
Solution
Accepted by eword

LVStudent wrote:

[...] I cannot call the case statement without using a sequence structure

 


Yes you can.  You just need to be clever.
 

LVStudent wrote: 

I don't think I can use a state machine to solve this problem.

 


 I think you probably can. 
As for your original post; what are these s1 and s2 of which you speak?  My take on it is that you want to select a case based on the values of more than one boolean control.  If this is correct, I like to do this:
 snap.jpg
Build your boolean controls into an array, convert the array to a number and feed this into your case structure.  Neither button pushed = 0, s1 only = 1, s2 only = 2, both = 3.   This works for as many booleans as you need and is an easy way to make a decision that depends on many inputs.

 

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 10 of 10
(3,820 Views)