|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Need Help With Case Statemet
In our teams code we have four case statements inside of each other and as a programmer I know that that is not ideal. I was wondering if anyone could help me solve this issue. We use Global Variables but do any of you know a way to make it so we don't have it like this.
|
|
#2
|
||||
|
||||
|
Re: Need Help With Case Statemet
What are you trying to get to happen here?
If all your case statements are true/false only, and the actions inside are just setting one output, you might do better using a combination of Select blocks (the labview equivalent of an if/then/else) and appropriate boolean operators to get a final result. Alternately, you could use a series of select blocks to choose a named state (using an ENUM value) that you feed to one case statement to pick the final result. |
|
#3
|
||||
|
||||
|
Re: Need Help With Case Statemet
Quote:
|
|
#4
|
|||
|
|||
|
Re: Need Help With Case Statemet
My first suggestion would be to select the loop containing the logic and click the cleanup button on the toolbar. It is the one with the small broom on it. That way we will be able to se how the logic and variables are attached.
In the attached image, I show three alternate ways to combine the logic and select values. i generally use one of the top two. If it is not only values that are changing, but alternate code, I'll use something more like the bottom one. By the way, the most important thing is that the code makes sense to you and works correctly. These alternate ways of writing it are suggestions, but be sure you understand them before redoing anything. I like to do this by writing the code in parallel, right next to the existing code. Then you can look at the old and new side-be-side and reason about it. You can review a truth table, sketch a graph, or whatever helps you to understand it and prove that the old and new code work the same. You can even leave most of the old and new code in, run them and compare the results as you run code. Greg McKaskle |
|
#5
|
||||
|
||||
|
Re: Need Help With Case Statemet
Thank you guys. I figured it out. I posted a photo of how I fixed it.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|