06-22-2018 03:32 PM - edited 06-22-2018 03:46 PM
Hi every one,
I have a problem with a nested case structure to solve an algorithm like this
help, please
06-22-2018 03:41 PM - edited 06-22-2018 03:43 PM
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?
06-22-2018 03:47 PM
You need to explain your flowchart. It might be easier to describe the problem you are trying to solve.
06-22-2018 03:52 PM
am sorry, I have edited the post,
I wonder how can I construct an algorithm like this without the nested case??
06-22-2018 04:07 PM
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
06-22-2018 04:15 PM - edited 06-22-2018 04:16 PM
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
06-22-2018 04:16 PM - edited 06-22-2018 04:21 PM
@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....
06-23-2018 03:00 AM - edited 06-23-2018 03:22 AM
thanks for reply altenbach, but this is not the answer I want
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?
06-23-2018 06:05 AM
This is sounding more like you should use a State Machine.
06-23-2018 11:30 AM - edited 06-23-2018 11:31 AM
@ssara wrote:
thanks for reply altenbach, but this is not the answer I want
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:
A single-shot event structure seems out of place here too.