LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

nested case

Hi every one,

I have a problem with a nested case structure to solve an algorithm like this

nested case.png

 

 

help, please 

0 Kudos
Message 1 of 10
(2,917 Views)

What's the difference between the two images in your post? (ahh, you removed one instance)

 

Why do you think you need nested case structures?

0 Kudos
Message 2 of 10
(2,911 Views)

You need to explain your flowchart. It might be easier to describe the problem you are trying to solve.

 

  • What is "H"
  • Where do B and D values come from? What are typical values?
  • What should X be if the outer case is FALSE?
  • Why is there a case in the TRUE case if there is no other decision for YES in the flow chart? (assuming YES=TRUE).
  • Is this a subVI? Seems to "end" no matter what branch we take.
0 Kudos
Message 3 of 10
(2,906 Views)

am sorry, I have edited the post,

I wonder how can I construct an algorithm like this without the nested case??

 

0 Kudos
Message 4 of 10
(2,898 Views)

I simplified my algorithm to like this because it is a large complicated alg.

H represents other codes including another if statement 

B and D come from outside the case

another case including H codes, not shown in the flowchart

the end just to display a message to the user   

 

0 Kudos
Message 5 of 10
(2,886 Views)

all the calculations after if statement are to calculate the x value,  it may be calculated in case 1 then recalculated (updated) in the next case

 

I edited the attached vi

0 Kudos
Message 6 of 10
(2,880 Views)

@ssara wrote:

 

B and D come from outside the case 


So why are the terminals inside the case then if the data comes from the outside?

What's the difference between "D" and "d"? Same? Why would it matter where D comes from if you change it to a constant? What should D be if the first decision is "yes"?

So what should happen after it displays a message to the user? What does H do based on the yes/no input? Does H care about any of the other values or just the final yes or no?

If D=1 and B+D should be >1, isn't that the same as B>0?

 

This would do about the same thing, probably....

 

Boo.png

 

Message 7 of 10
(2,879 Views)

thanks for reply altenbach, but this is not the answer I want Smiley Sad

I have many if statements inside a for loop in each iteration all terminals have initial values (like x here), in each case structure this value may be updated according to conditions. in the outer case (case1 ), if the condition is true the x will updated, then if the inner condition is false (case 2) (according to x value) the execution must go to H which has another condition to compare x then updated its value and so on .

should I use sequence structure?

0 Kudos
Message 8 of 10
(2,836 Views)

This is sounding more like you should use a 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 9 of 10
(2,827 Views)

@ssara wrote:

thanks for reply altenbach, but this is not the answer I want Smiley Sad

 


The quality of the answer can typically not be much better than the quality of the question and your question was so full of holes, it could be called swiss cheese.

If you want a solution, it is not sufficient to give some partial specifications and you have not answered most of my earlier questions to clarify.

 

Now you are attaching code that contains a boatload of local variables where none are needed. All you need are the terminals and you would wire to all the places where the values are used. The wire is the variable!

What is the total number of possible "some code" versions that needs to be executed? Do some of the inner cases share the same code? Make a single case structure that contains a case for each unique possibility and do some logic to calculate the case to be active based on the three parameters.

 

Currently, each parameter has only two choices. so you could combine them into a three-bit number for 8 possible cases. (0..7)

 

Here is one possibility to get you started:

 

MultiCase.png

 

A single-shot event structure seems out of place here too.

0 Kudos
Message 10 of 10
(2,813 Views)